class person{
private:
int age;
public:
char name[7];
person(const char* n, int a){
strcpy(name, n);
age = a;
}
void getAge(){
return age ;
}
int setAge(int newAge){
age = newAge;
}
virtual void display(){
Serial.print("Age: "); Serial.println(age);
Serial.print("Name: "); Serial.println(name);
}
};
class employee : public person {
public :
char department[10];
employee(const char* n, int a, const char* d)
:person(n, a){
strcpy(department, d);
}
void display()override{
person:: display();
Serial.print("Department: "); Serial.println(department);}
};
void setup() {Serial.begin(115200);
// put your setup code here, to run once:
Serial.println("original data: ");
employee frank1("frank", 45, "office");
frank1.display();
Serial.println();
frank1.setAge(50);
Serial.println("New data: ");
employee frank("frank", 45, "office");
frank1.display();
Serial.println();
}
void loop() {
// put your main code here, to run repeatedly:
}