include iostream using namespace std class Test private char var1 char

 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
27
28
29
30
31
32
33
34
35
36
37
#include <iostream>
using namespace std;
class Test{
private:
char var1;
char var2;
public:
Test(char tempVar1, char tempVar2){
var1 = tempVar1;
var2 = tempVar2;
}
~Test(){
cout<<"Destruktor"<<endl;
}
friend Test& operator--(Test &obj, int)
{
int t = obj.var1;
t--;
obj.var1 = t;
return obj;
}
void display(){
cout << var1 << " " << var2;
}
};
int main()
{
Test firstTest('t', 'y');
Test secondTest('x', 'z');
firstTest--;
--secondTest;
firstTest.display();
return 0;
}