How to Inherit Class into Structure using C++ | Class Inherit Struct C++ with Example
In This Post We Learn How to Inherit Class into Structure using C++
Program Source Code
#include<iostream>
#include<string.h>
using namespace std;
struct Person{
char name[20];
};
class Student : private Person{
public:
void setName(char n[]){
strcpy(name,n);
}
void show(){
cout<<"Name is :"<<name;
}
};
main(){
Student objS;
objS.setName("Abdullah Dogar");
objS.show();
}
Post a Comment