#include<iostream>
using namespace std;
class test
{
public:
int a,b;
void set()
{
this->a=4;
(*this).b=5;
cout<<(*this).a<<"\n<<this->b;
}
};
int main()
{
test aaa;
aaa.set();
return 0;
}
Output:
4
5
……………………
#include<iostream>
using namespace std;
class aaa
{
public:
int value;
void display()
{
this->value=20;
cout<<"Address:"<<this<<"\n";
}
};
int main()
{
aaa b;
b.display();
return 0;
}
Output of the above program gives the address of the object.
using namespace std;
class test
{
public:
int a,b;
void set()
{
this->a=4;
(*this).b=5;
cout<<(*this).a<<"\n<<this->b;
}
};
int main()
{
test aaa;
aaa.set();
return 0;
}
Output:
4
5
……………………
#include<iostream>
using namespace std;
class aaa
{
public:
int value;
void display()
{
this->value=20;
cout<<"Address:"<<this<<"\n";
}
};
int main()
{
aaa b;
b.display();
return 0;
}
Output of the above program gives the address of the object.
Too good and very important for b.tech. OOPS paper examination.
ReplyDelete