Created
September 15, 2012 15:29
-
-
Save kimkidong/3728467 to your computer and use it in GitHub Desktop.
[Blog] this pointer instruction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
class Date | |
{ | |
protected: | |
int month; | |
int day; | |
public: | |
Date(){std::cout<<"this pointer is "<<this<<std::endl;} | |
~Date(){}; | |
Date& SetMonth(int month) | |
{ | |
this->month = month; | |
return *this; | |
} | |
Date& SetDay(int day) | |
{ | |
this->day = day; | |
return *this; | |
} | |
Date& ShowDate() | |
{ | |
std::cout<<this->month<<"월"<<this->day<<"일 입니다."<<std::endl; | |
return *this; | |
} | |
}; | |
void main() | |
{ | |
Date* d = new Date; | |
d->SetMonth(9).SetDay(16).ShowDate(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment