Created
April 27, 2016 05:54
-
-
Save lasagnaphil/6b4f340c5a6c39d52a8304b162869d15 to your computer and use it in GitHub Desktop.
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> | |
using namespace std; | |
class A | |
{ | |
public: | |
A(int = 1); | |
A(const A&); | |
void print(); | |
void printX() { | |
cout << X << endl; | |
} | |
private: | |
int X; | |
const int Y; | |
}; | |
A::A(int value) : X(value), Y(7) {} | |
A::A(const A& a) : X(3), Y(2) {} | |
void A::print() | |
{ | |
cout << X << endl; | |
cout << Y << endl; | |
} | |
int main() { | |
A t(12); | |
A s = t; | |
t.print(); | |
s.print(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment