Skip to content

Instantly share code, notes, and snippets.

@kimkidong
Created September 15, 2012 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kimkidong/3728467 to your computer and use it in GitHub Desktop.
Save kimkidong/3728467 to your computer and use it in GitHub Desktop.
[Blog] this pointer instruction
#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