Question

In: Computer Science

Class object in C++ programming language description about lesson copy constructor example.

Class object in C++ programming language description about lesson copy constructor example.

Solutions

Expert Solution

#include

#include

#include

using namespace std;

class emp{

  private:

    char name[30];

    float salary;

  public:

    float getsalary();

    emp(const char[]="Seyha",float=0.0);

    emp(const emp &a);

    ~emp();

    void input();

    void print();

};

emp::emp(const char *nm, float salary)

:salary(salary){

  strcpy(name,nm);

}

emp::~emp(){

  cout<<" Calling destructor... "<

}

emp::emp(const emp &a){

  strcpy(this->name,a.name);

  this->salary=a.salary;

  cout<<" Calling copy constructor..."<

}

void emp::input(){

  cout<<" Enter name: ";cin.getline(name,30);

  cout<<" Enter Salary: ";cin>>salary;

  cin.sync();

}

void emp::print(){

  cout<

}

float emp::getsalary(){          //no

  return salary;

}

 

void infor(emp em){          //NO

 

  em.print();

  if(em.getsalary()>=1000){

    cout<<" You got too hight salary "<

  }else

    cout<<" Try more to get a higher salary"<

}

int main(){

  emp obj1("Run seyha",1700);

  emp obj2(obj1);

  emp obj3=obj2;

  obj1.print();

  obj2.print();

  obj3.print();

  infor(obj1);

  

}


Related Solutions

Class object in C++ programming language description about lesson inheritance example.
Class object in C++ programming language description about lesson inheritance example.
Class object in C++ programming language description about lesson inheritance example.
Class object in C++ programming language description about lesson inheritance example.
Class object in C++ programming language description about lesson Overloading function example.
Class object in C++ programming language description about lesson Overloading function example.
Class object in C++ programming language description about lesson static variable example.
Class object in C++ programming language description about lesson static variable example.
Class object in C++ programming language description about lesson base class and derived class example.
Class object in C++ programming language description about lesson base class and derived class example.
Class object in C++ programming language description about lesson inheritance multi level example.
Class object in C++ programming language description about lesson inheritance multi level example.
Class object in C++ programming language description about lesson unary overloading function example.
Class object in C++ programming language description about lesson unary overloading function example.
Code in C++ programming language description about chose favorite fruit and wage color of fruit in lesson Class object (Multiple class).
Code in C++ programming language description about chose favorite fruit and wage  color of fruit in lesson Class object (Multiple class).
Code in C++ programming language description about lesson Calculator (multiple, sum, dived, sub) example.
Code in C++ programming language description about lesson Calculator (multiple, sum, dived,  sub) example.
Code in C++ programming language description about read and write data to memory example.
Code in C++ programming language description about read and write data to memory example.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT