목록C++ (19)
Typing diary
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647#include using namespace std; class ex{ int var1 = 0; int var2 = 0;public: ex& operator +(ex& op1); //이항 연산자 함수 선언 (연속적으로 연산가 작동하게 하기 위핸선 리턴 타입을 ex&와 같이 선언 해야함) ex operator ++(); //단항 전위 연산자 함수 선언 //ex operator ++(int x); 단항 후위 연산자 함수 선언 friend ex& operator+(int op1, ex op2); //friend를 이용한 연산자 함수 선언}; //이항 연산자 함..
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 #include using namespace std; class Class { static int sv; int v; public: static int func() { sv = 1; //this->v = 1; ┐ //this->sv = 1; ┴> static 멤버 함수는 this를 사용할 수 없다. //v = 1; static 멤버 함수는 오직 static 멤버들만 접근 가능하다. } }; int Class::sv = 1; //static 멤버 변수는 외부에 전역 변수로 선언되어야 한다! (초기화를 안하더라도 전역 변수로 선언해야한다. 안할시 링크 오류 발생) int main() { Class::f..
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 #include #include using namespace std; class Trace { static string tag[100], log[100]; static int count; public: static void put(const char* t,const char* l); static void print(const char* t = NULL); }; str..
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566#include #include using namespace std; class Histogram{ string sen; int totCount = 0; int Count[26] = { 0 };public: Histogram(string sen); Histogram& operator