목록C++ (19)
Typing diary
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263#include #include using namespace std; class Histogram{ string sentence; int isAlphaCount = 0; int AlphaCount[26] = { 0 };public: Histogram(string sentence) { this->sentence = sentence; this->sentence += '\n'; } void put(string sentence); void putc(char c); void print(); }; void H..
1234567891011121314151617181920212223242526272829303132#include #include using namespace std; class Circle{ int radius;public: Circle() {} ~Circle() {}}; void func(Circle circle) { //함수 종료시 circle의 소멸자만 실행된다.} int main(){ /*※값에 의한 호출 (call by value) 주소에 의한 호출 (call by address) 참초에 의한 호출 (call by reference) */ Circle waffle; // func(waffle); //waffle의 내용이 그대로 func에 복사 (이때 복사된 Circle클래스의 생성자 대신 복사..
12345678910111213141516171819202122232425262728293031323334#include #include using namespace std; class Circle{ int radius; char* name;public: Circle() {} Circle(Circle& c); //복사 생성자 선언 (선언을 안하더라도 컴파일러에서 디폴트 복사 생성자를 삽입한다.)}; Circle::Circle(Circle & c) //복사 생성자 구현(디폴트 생성자는 얕은 복사를 하기 때문에 복사 생성자를 새로 구현해야 한다.){ //깊은 복사 생성자 this->radius = c.radius; this->name = new char[strlen(c.name) + 1]; strcpy(th..