Write a program to illustrate the use of this pointer.
CODING:
#include<iostream.h>
#include<conio.h>
class t
{
int a;
public:
void setdata(int a)
{
this->a=a;
}
void disp()
{
cout<<a;
}
};
void main()
{
t t1;
clrscr();
t1.setdata(10);
t1.disp();
getch();
}
CODING:
#include<iostream.h>
#include<conio.h>
class t
{
int a;
public:
void setdata(int a)
{
this->a=a;
}
void disp()
{
cout<<a;
}
};
void main()
{
t t1;
clrscr();
t1.setdata(10);
t1.disp();
getch();
}
Comments
Post a Comment