Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
392 B
0
Indexable
Never
 namespace std;
class one{
public:
    int num;
    void setnum(int x){
    num = x;}
    void shownum(){
    cout<<"Base Class: num ="<<num<<endl;}
};
class two: public one{
public:
    void shownums(){
    cout<<"Derived Class: num="<<num<<endl;
    }
};
int main(){
    two ob;
    ob.num = 5;
    ob.shownum();
    ob.setnum(10);
    ob.shownums();
    return 0;
}