본문 바로가기

반응형

전체 글

(199)
[C++]생성자(Constructor) [[연습문제 1]] #include using std::cout; using std::endl; using std::cin; class T { public: T(); T(int n); T(int a1,double a2, char b); T(char a); T(char *p); T(int a1, int a2, char *p); }; int main() { T ob, ob2, ob3; //객체 생성 T ob4(100); //객체 생성 시 인수전달 T ob5(10, 20.34, 'B'); T ob6('a'); T ob7; T ob8("Hello"); T ob9(50, 60, "Happy Birthday"); return 0; } T::T() { cout
[C++]객체지향2 [[DynamicArray.h]] #ifndef _DYNAMICARRAY_H_ #define _DYNAMICARRAY_H_ class DynamicArray{ private: int *IntAR; int _AR; int temp; int i,j; public: void Alloc(int n); void Input(); void Output(); void Sort(int _sort); void Free(); }; #endif [[main.cpp]] #include #include "DynamicArray.h" using std::cin; using std::cout; int main() { int n; cout > n; DynamicArray da; da.Alloc(n); da.Input(); cout
[C++]객체지향(OOP) [[연습문제 1]] >Point.hsetpoint.cpp100 || _y >100) { x = y = -1; } else { x=_x; y=_y; } } void Point::ShowPoint() { if(x == -1 && y == -1) cout
[C++]파일분할 [[확인문제 1]] >ACC.hmain.cppacc.cpp
[C++]동적할당3 #include #include using std::cin; using std::cout; using std::endl; #define MEMO_CNT 5 #define MEMO_LENGTH 1024 int main() { char *p[MEMO_CNT]; char buf[MEMO_LENGTH]; char *conch[MEMO_CNT]; for(int i=0; i
[C++]구조체와 클래스 #include #include #include using std::cin; using std::cout; using std::endl; class ACC { public: int accID; char pw[5]; char name[20]; int bal; void menu(int &sel); void mkacc(); void save(); void withdraw(); void balance(); }; int main() { ACC reval = {1111}; int choice; while(1) { reval.menu(choice); switch(choice) { case 1: reval.mkacc(); break; case 2: reval.save(); break; case 3: reval.with..
[C++]클래스 [[연습문제 1]] #include using std::cin; using std::cout; using std::endl; class ACC { public: int accId; char pw[5]; char name[20]; int bal; void showdata(); void deposit(); void withdraw(); }; int main() { ACC ac = {1111, "1234", "오세혁", 5000}; ac.showdata(); ac.deposit(); ac.withdraw(); ac.showdata(); return 0; } void ACC::showdata() { cout
[C++]동적할당2 [[확인문제 1]] #include #include using std::cin; using std::cout; using std::endl; #define MEMO_CNT 5 #define MEMO_LENGTH 1024 int main() { char *p[MEMO_CNT]; char buf[MEMO_LENGTH]; char len[MEMO_LENGTH]; for(int i=0; i < MEMO_CNT; i++) { cout

반응형