language: C++ 4.7.2 (gcc-4.7.2)
date: 335 days 9 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
class sample
{
private : 
  int x;
public :
  sample(int x =0)
  {
    this->x = x;
  }
};
 
sample::sample operator+(sample s)
{
  this->x = this->x + s.x;
  return *this;
}
 
 
 
  int  main()
    {
      sample s1(10);
      sample s2;
      s2 = s2 + s1;
      return 0;    
    }
prog.cpp: In function ‘sample operator+(sample)’:
prog.cpp:14: error: invalid use of ‘this’ in non-member function
prog.cpp:14: error: invalid use of ‘this’ in non-member function
prog.cpp:4: error: ‘int sample::x’ is private
prog.cpp:14: error: within this context
prog.cpp:15: error: invalid use of ‘this’ in non-member function
prog.cpp: In function ‘int main()’:
prog.cpp:24: error: no match for ‘operator+’ in ‘s2 + s1’
prog.cpp:12: note: candidates are: sample operator+(sample)