#include<iostream>
using namespace std;
class complex
{
int a,b;
public:
void set_data(int a,int b)
{
this->a=a;
this->b=b;
}
void show_data()
{
cout<<a<<"+"<<b<<"i";
}
complex add(complex c)
{
complex temp;
temp.a=a+c.a;
temp.b=b+c.b;
return temp;
}
};
int main()
{
complex c1,c2;
c1.set_data(5,6);`
c2.set_data(4,5);
complex c3=c1.add(c2);
c3.show_data();
}
here temp and c are accessing a and b by . operator
why temp and c can access a and b private variables using dot operator???
but private variables are not accessible outside of class.