Write a program that would print the information (name, year of joining, salary, address) of the employee by creating a class named employee.The output should be as fallow.
Name year of joining address
Robert 1994 64C- wallstreat
Sam 2000 68D- wallstreat
John 1999 26B- wallstreat
#include <iostream>
#include <string>
using namespace std;
class Employee
{
private:
string name;
int year;
string address;
public:
void Initialize(string n, int y, string a)
{
name = n;
year = y;
address = a;
}
void Display()
{
cout << name << "\t" << year << "\t" << address << endl;
}
};
int main()
{
cout << "Name year of joining address\n";
Employee e;
e.Initialize("Robert", 1994, "64C- wallsteat");
e.Display();
e.Initialize("Sam", 2000, "68D- wallsteat");
e.Display();
e.Initialize("John", 1999, "26B- wallsteat");
e.Display();
return 0;
}
Comments
Leave a comment