[ create a new paste ] login | about

Link: http://codepad.org/Rz5LQbYT    [ raw code | output | fork ]

C++, pasted on Oct 19:
#include <iostream>
class A
{
private:
int x;
public:
A operator+(const A&) const;
};
A A::operator+(const A& b) const
{
A a;
a.x = x + b.x;
return a;
}
int main()
{
using namespace std;
A a;
a.x = 3;
A b;
b.x = 3;
A c = a + b;
cout << c.x;
}


Output:
1
2
3
In function 'int main()':
Line 5: error: 'int A::x' is private
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: