Posts

Showing posts with the label oop

inheritance in cpp

Image
Hello From Iqbal; welcome to My Blog;in the program below i am going to use famous Object Oriented Programming Properties i.e.   Inheritance ,   Encapsulation     Method Overriding feel free to comment if you have any question(s). #include <iostream> using namespace std; class Person{    // person class , the base class from whihc further classes will inherit private : // encapsulated private members(data fields) string profession; int age; public: Person(){ } void setAge(int a){    //setters ( mutators) this->age=a; } void setProfession(string prof){ this->profession = prof; } int getAge()  {  //getters (accessors) return age; } string getProfession()  { return profession; } void display(){ cout<<"my Profession is"<<profession<<"\n"; cout<<"my age is: "<<age<<"\n"; walk(); talk...