본문 바로가기

컴퓨터

전역함수에 대한 friend 선언 #include using std::cout; using std::endl; class Counter { int val; public: Counter(){ val=0; } void Print() const { cout 더보기
this 포인터의 용도 #include using std::cout; using std::endl; class Data { int aaa; int bbb; public: Data(int aaa, int bbb) { cout 더보기
객체 포인터 배열 #include using std::cout; using std::endl; class Point { int x; int y; public: Point(){ cout 더보기
객체 배열과 생성자 #include using std::cout; using std::endl; class Point { int x; int y; public: Point(){ cout 더보기
소멸자를 통한 메모리 공간 해제 #include using std::cout; using std::endl; class Person { char *name; char *phone; int age; public: Person(char* _name, char* _phone, int _age); void ShowData(); ~Person(); }; Person::Person(char* _name, char* _phone, int _age) { name=new char[strlen(_name)+1]; strcpy(name, _name); phone=new char[strlen(_phone)+1]; strcpy(phone, _phone); age=_age; } void Person::ShowData() { cout 더보기
소멸자 #include using std::cout; using std::endl; class AAA { public: AAA() { cout 더보기
생성자와 동적할당 및 해제 #include using std::cout; using std::endl; class Person { char *name; char *phone; int age; public: Person(char* _name, char* _phone, int _age); void ShowData(); void DelMemoty(); }; Person::Person(char* _name, char* _phone, int _age) { name=new char[strlen(_name)+1]; strcpy(name, _name); phone=new char[strlen(_phone)+1]; strcpy(phone, _phone); age=_age; } void Person::ShowData() { cout 더보기
생성자와 동적할당 #include using std::cout; using std::endl; class Person { char *name; char *phone; int age; public: Person(char* _name, char* _phone, int _age); void ShowData(); }; Person::Person(char* _name, char* _phone, int _age) { name=new char[strlen(_name)+1]; strcpy(name, _name); phone=new char[strlen(_phone)+1]; strcpy(phone, _phone); age=_age; } void Person::ShowData() { cout 더보기
생성자 오버로딩 #include using std::cout; using std::endl; class Point { int x, y; public: Point() { x=y=0; } Point(int _x, int _y) { x=_x, y=_y; } void ShowData() { cout 더보기
생성자 #include using std::cout; using std::endl; const int SIZE=20; class AAA { int i, j; public: AAA() { cout 더보기