Define a function outside a using scope resolution operators.
CODING:
#include<iostream.h>
#include<conio.h>
class t{
int a;
public:
void setdata();
void disp()
{
cout<<a;
}
};
void t::setdata()
{
a=15;
}
void main()
{
t obj1;
clrscr();
obj1.setdata();
obj1.disp();
getch();
}
CODING:
#include<iostream.h>
#include<conio.h>
class t{
int a;
public:
void setdata();
void disp()
{
cout<<a;
}
};
void t::setdata()
{
a=15;
}
void main()
{
t obj1;
clrscr();
obj1.setdata();
obj1.disp();
getch();
}
Comments
Post a Comment