Hello everyone! I create a class and inside it a make a function which is refered to the specific class. Inside the specific function i make use of "*this" and i have a problem.Forgive me if i am lisened a litle naive but i haven't much experience of "this" pointer yet.Take a look:
class one
{
public:
int a,b;
one(int l,int k){a=l;b=k;}
one& kalamari(one tsiou);
private:
};
one& one::kalamari(one tsiou)
{
a+=tsiou.a;
b+=tsiou.b;
cout<<"this-->"<<*this.a<<endl;//Here is my question
return *this;
}
(Corect me if i am wrong)Since "this" is a pointer which is refering to the element one i thought i could use it to return only one part of this element,thus :
cout<<"this-->"<<*this.a<<endl;//Here is my question
But my compiler returns me an error, Why i can't do that?Is there anything you can suggest? Thanks for your time.