This is a simple program
#include <iostream>
using namespace std;
class Employee
{
public:
Employee(string="default", int=10){};
void display();
private:
static int x;
static string s;
};
int Employee::x=7;
string Employee::s="Johnson";
void Employee::display()
{
cout << s << x << endl;
}
int main()
{
int num;
string name;
Employee e1;
Employee e2("Arthur",33);
e2.Employee::display();
}
I have the following questions
1) I need help understanding why the output of the program is Johnson7
and not Arthur33
( i know it has something to do with static variables )
2) Normally a constructor is defined as such Employee(string,int)
What does the parameters string="default",int=10 in the constructor
Employee(string="default", int=10){};
actually mean ???