hello igmou students hope you all fine...
i am also one from the same cader.
here is the sloved assignment of cs-72 c++ 2012 , latest solved by me.
here the program for second question derived from above program, just i have add some oveloaded constructor, virtual functon for runtime polymorphism , function overloading(compile time polymorphism),
inheritance for deriving class manager,encapsulation which is basic for defining class, etc.
#include <iostream.h>
#include <conio.h>
class employee // encapsulation.......
{
public:
int empid;
char *name;
char *department;
char *designation;
char *dob;
employee()
{}
employee(int id,char *tname,char *dep,char *des,char *tdob) // overloaded cons.......with diff number of parameter
{
empid=id;
name=tname;
department=dep;
designation=des;
dob=tdob;
}
virtual void display() // virtual fun for runtime poli....
{
cout<<"This is employee:"<<endl;
cout<<"Emp_id: "<<empid<<endl;
cout<<"Name: "<<name<<endl;
cout<<"Department: "<<department<<endl;
cout<<"Designaton: "<<designation<<endl;
cout<<"Date of birth: "<<dob<<endl;
}
void update(char *tdep,char *tdes); // function overloading compile time poli.....
void update(int id,char *tname); // function overloading compile time poli.....
employee(int id,char *tname,char *dep,char *des) // overloaded cons......with diff number of parameter
{
empid=id;
name=tname;
department=dep;
designation=des;
// dob=tdob;
}
};
void employee::update(char *tdep,char *tdes)
{
department=tdep;
designation=tdes;
}
void employee::update(int id,char *tname)
{
empid=id;
name=tname;
}
class manager : public employee // inheritance.......
{
private:
char *managesdep;
public:
manager()
{}
manager(int id,char *tname,char *dep,char *des,char *tdob) : employee(id,tname,dep,des,tdob)
{
}
void display() // virtual inside manager.....
{
cout<<"this employee is manager:"<<endl;
cout<<"Emp_id: "<<empid<<endl;
cout<<"Name: "<<name<<endl;
cout<<"Department: "<<department<<endl;
cout<<"Designaton: "<<designation<<endl;
cout<<"Date of birth: "<<dob<<endl;
cout<<"Name of department that manager manage: "<<managesdep<<endl;
}
void update(char *tdep,char *tdes,char *tmandep)
{
department=tdep;
designation=tdes;
managesdep=tmandep;
}
void mgetdata()
{
cout<<"Enter department that manager handels: "<<endl;
cin>>managesdep;
}
};
void main()
{ employee *p,e2;
employee e1(1,"hiren","production","clerk","2-2-1987");
employee e3(7,"hiren","production","clerk");
manager m2;
manager m1(3,"hiren","production","manager","2-2-1987");
clrscr();
cout<<"Employee data before update:"<<endl;
p=&e3;
p-> display(); // implement runtime poli....using pointer......
cout<<endl;
cout<<"Employee data before update this is constucted throgh cons with dob parameter:"<<endl;
p=&e1;
p-> display();
cout<<endl;
e1.update("hr","manager"); //compile time poli....
cout<<"Employee data after updating dep and des: "<<endl;
cout<<endl;
p=&e1;
p-> display();
cout<<endl;
e1.update(5,"Suresh"); //compile time poli....
cout<<"Employee data after updating name and id:"<<endl;
p=&e1;
p-> display();
cout<<endl;
cout<<"Manager data before update:"<<endl;
p=&m1;
p-> display();
cout<<endl;
m1.update("finance","manager","sales");
cout<<"Manager data after update:"<<endl;
p=&m1;
p-> display();
cout<<endl;
getch();
}
for runnable .cpp files contact me at hi0001234d@gmail.com
for more aanswers please wait some time.....
i am also one from the same cader.
here is the sloved assignment of cs-72 c++ 2012 , latest solved by me.
1) Create a class named employee that stores the employee ID, employee name, date of birth, date of joining, designation and department. The class should include a constructor that initializes an object of that class, a member function that modifies the value of department and designation and a function to print all the information of the class. Explain the features of the term Class and Object in the context of object oriented programming in the context of the class you have created.
List the private and public members (data members as well as member functions) for the class employee. Define the data types of member variables using C++ and create few objects of the class. (8 Marks)
#include <iostream.h>
#include <conio.h>
class employee
{
public:
int empid;
char *name;
char *department;
char *designation;
char *dob;
employee()
{}
employee(int id,char *tname,char *dep,char *des,char *tdob)
{
empid=id;
name=tname;
department=dep;
designation=des;
dob=tdob;
}
virtual void display()
{
cout<<"This is employee:"<<endl;
cout<<"Emp_id: "<<empid<<endl;
cout<<"Name: "<<name<<endl;
cout<<"Department: "<<department<<endl;
cout<<"Designaton: "<<designation<<endl;
cout<<"Date of birth: "<<dob<<endl;
}
void update(char *tdep,char *tdes);
void employee::update(char *tdep,char *tdes)
{
department=tdep;
designation=tdes;
}
void main()
{ employee *p,e2;
employee e1(1,"hiren","production","clerk","2-2-1987");
e1.update("hr","manager");
cout<<"Employee data after updating dep and des: "<<endl;
cout<<endl;
p=&e1;
// p-> display();
cout<<endl;
cout<<"Employee data before update this is constucted throgh cons with dob parameter:"<<endl;
p=&e1;
p-> display();
cout<<endl;
e1.update("hr","manager");
cout<<"Employee data after updating dep and des: "<<endl;
cout<<endl;
p=&e1;
p-> display();
cout<<endl;
getch();
}
#include <conio.h>
class employee
{
public:
int empid;
char *name;
char *department;
char *designation;
char *dob;
employee()
{}
employee(int id,char *tname,char *dep,char *des,char *tdob)
{
empid=id;
name=tname;
department=dep;
designation=des;
dob=tdob;
}
virtual void display()
{
cout<<"This is employee:"<<endl;
cout<<"Emp_id: "<<empid<<endl;
cout<<"Name: "<<name<<endl;
cout<<"Department: "<<department<<endl;
cout<<"Designaton: "<<designation<<endl;
cout<<"Date of birth: "<<dob<<endl;
}
void update(char *tdep,char *tdes);
void employee::update(char *tdep,char *tdes)
{
department=tdep;
designation=tdes;
}
void main()
{ employee *p,e2;
employee e1(1,"hiren","production","clerk","2-2-1987");
e1.update("hr","manager");
cout<<"Employee data after updating dep and des: "<<endl;
cout<<endl;
p=&e1;
// p-> display();
cout<<endl;
cout<<"Employee data before update this is constucted throgh cons with dob parameter:"<<endl;
p=&e1;
p-> display();
cout<<endl;
e1.update("hr","manager");
cout<<"Employee data after updating dep and des: "<<endl;
cout<<endl;
p=&e1;
p-> display();
cout<<endl;
getch();
}
class defination: //explain class defination on your own.. it's easy
2) Create another class Manger, which is a derived class of the class employee. A manager may be working in a department but managing a different department. Thus, this class has extra information- Manages Department. Create the class managers as a sub class of class employee. You must use the following concepts while deriving the classes (Please also write the appropriate main( ) to demonstrate the concepts):
(a) Overloaded Constructors
(b) Encapsulation
(c) Inheritance
(d) Polymorphism
Explain how and where in your classes – employee and managers the concepts listed above have been demonstrated. here the program for second question derived from above program, just i have add some oveloaded constructor, virtual functon for runtime polymorphism , function overloading(compile time polymorphism),
inheritance for deriving class manager,encapsulation which is basic for defining class, etc.
#include <iostream.h>
#include <conio.h>
class employee // encapsulation.......
{
public:
int empid;
char *name;
char *department;
char *designation;
char *dob;
employee()
{}
employee(int id,char *tname,char *dep,char *des,char *tdob) // overloaded cons.......with diff number of parameter
{
empid=id;
name=tname;
department=dep;
designation=des;
dob=tdob;
}
virtual void display() // virtual fun for runtime poli....
{
cout<<"This is employee:"<<endl;
cout<<"Emp_id: "<<empid<<endl;
cout<<"Name: "<<name<<endl;
cout<<"Department: "<<department<<endl;
cout<<"Designaton: "<<designation<<endl;
cout<<"Date of birth: "<<dob<<endl;
}
void update(char *tdep,char *tdes); // function overloading compile time poli.....
void update(int id,char *tname); // function overloading compile time poli.....
employee(int id,char *tname,char *dep,char *des) // overloaded cons......with diff number of parameter
{
empid=id;
name=tname;
department=dep;
designation=des;
// dob=tdob;
}
};
void employee::update(char *tdep,char *tdes)
{
department=tdep;
designation=tdes;
}
void employee::update(int id,char *tname)
{
empid=id;
name=tname;
}
class manager : public employee // inheritance.......
{
private:
char *managesdep;
public:
manager()
{}
manager(int id,char *tname,char *dep,char *des,char *tdob) : employee(id,tname,dep,des,tdob)
{
}
void display() // virtual inside manager.....
{
cout<<"this employee is manager:"<<endl;
cout<<"Emp_id: "<<empid<<endl;
cout<<"Name: "<<name<<endl;
cout<<"Department: "<<department<<endl;
cout<<"Designaton: "<<designation<<endl;
cout<<"Date of birth: "<<dob<<endl;
cout<<"Name of department that manager manage: "<<managesdep<<endl;
}
void update(char *tdep,char *tdes,char *tmandep)
{
department=tdep;
designation=tdes;
managesdep=tmandep;
}
void mgetdata()
{
cout<<"Enter department that manager handels: "<<endl;
cin>>managesdep;
}
};
void main()
{ employee *p,e2;
employee e1(1,"hiren","production","clerk","2-2-1987");
employee e3(7,"hiren","production","clerk");
manager m2;
manager m1(3,"hiren","production","manager","2-2-1987");
clrscr();
cout<<"Employee data before update:"<<endl;
p=&e3;
p-> display(); // implement runtime poli....using pointer......
cout<<endl;
cout<<"Employee data before update this is constucted throgh cons with dob parameter:"<<endl;
p=&e1;
p-> display();
cout<<endl;
e1.update("hr","manager"); //compile time poli....
cout<<"Employee data after updating dep and des: "<<endl;
cout<<endl;
p=&e1;
p-> display();
cout<<endl;
e1.update(5,"Suresh"); //compile time poli....
cout<<"Employee data after updating name and id:"<<endl;
p=&e1;
p-> display();
cout<<endl;
cout<<"Manager data before update:"<<endl;
p=&m1;
p-> display();
cout<<endl;
m1.update("finance","manager","sales");
cout<<"Manager data after update:"<<endl;
p=&m1;
p-> display();
cout<<endl;
getch();
}
for runnable .cpp files contact me at hi0001234d@gmail.com
for more aanswers please wait some time.....
So in the second program of this paper do we have to add the the first program..???? Thanks for the help... Plz Reply..
ReplyDeleteHi Ravi
Deletewell it is better to add program as a reference in second question
it is still better if you post here both questions as at a time i don't have access to questions, then we can clear it out