#include<iostream.h>
#include<conio.h>
class aa
{
protected:
int n;
public:
void get()
{
cout<<"enter no";
cin>>n;
}
};
class bb : public aa //the keyword public specifies that objects of the derived class are able to access public member functions of the base class.
{ //the alternative is the keyword private/protected. when this is used, objects of the derived class can't access public member functions of the
public: //base class.
void show()
{
cout<<endl<<n<<endl;
}
};
class cc: public aa //the difference b/w publicly derivedand privately derived class is: objects of the publicly derived class can access public members
{ //of the base class, while objects of privatly derived class can't; they can only access the public members of their own derived class
public:
void show()
{
cout<<endl<<--n<<endl;
}
};
void main()
{
bb objb;
cc objc;
objb. get();
objb.show();
objc.get();
objc.show();
getch();
}
#include<conio.h>
class aa
{
protected:
int n;
public:
void get()
{
cout<<"enter no";
cin>>n;
}
};
class bb : public aa //the keyword public specifies that objects of the derived class are able to access public member functions of the base class.
{ //the alternative is the keyword private/protected. when this is used, objects of the derived class can't access public member functions of the
public: //base class.
void show()
{
cout<<endl<<n<<endl;
}
};
class cc: public aa //the difference b/w publicly derivedand privately derived class is: objects of the publicly derived class can access public members
{ //of the base class, while objects of privatly derived class can't; they can only access the public members of their own derived class
public:
void show()
{
cout<<endl<<--n<<endl;
}
};
void main()
{
bb objb;
cc objc;
objb. get();
objb.show();
objc.get();
objc.show();
getch();
}
0 comments:
Post a Comment