Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Colour
- {
- public:
- static const Colour Red;
- static const Colour Green;
- static const Colour Blue;
- Colour(){}
- bool operator==(const Colour &other) const{
- if(other.colourCode == this->colourCode){return true;}else{return false;}
- }
- Colour & operator=(const Colour & other){
- this->colourCode = other.colourCode;
- }
- Colour(const Colour & other){
- *this = other;}
- private:
- int colourCode;
- Colour(int colourCodeIn){
- colourCode = colourCodeIn;
- }
- };
- const Colour Colour::Red(1);
- const Colour Colour::Green(2);
- const Colour Colour::Blue(3);
- class Pen
- {
- public:
- Pen(){}
- void setColour(const Colour & infarbe){
- farbe = infarbe;
- }
- Colour farbe;
- };
- int main()
- {
- Pen myPen1;
- myPen1.setColour(Colour::Blue);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement