Employee class code outputs

Recently I got this written test qns which seems tricky at least for me. Can someone guide me along how to get the 4 outputs? Tks.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <iostream>
using namespace std;

class Employee
{
	public:
			Employee (string = "default", int = 10){}
			void display();
			void set (string, int);
			int get (string&, int&);
			void fct();
	private:
			static int x;
			static string s;
};

int Employee::x=7;
string Employee::s="Ligia";

void Employee::display()
{
	cout << s << x << endl;
}

void Employee::set(string k, int n)
{
	n++;
	x=n;
	s=k;
}

int Employee::get(string& k, int& n)
{
	k=s+"k";
	n=x+7;
	return n;
}

void Employee::fct()
{
	s="tt";
	x=x+7;
}

int main()
{
	int num;
	string name;
	Employee e1;
	Employee e2("Rita", 13);
	e2.Employee::display();
	
	e2.set("Veronica",25);
	e2.get(name, num);
	e2.Employee::display();
	e2.fct();
	e2.Employee::fct();
	e2.Employee::display();
	e1.Employee::fct();
	e1.Employee::display();
	
	return 0;
}

You must include the string header to use the string object:

#include<string>
I am actually checking on how to tackle such qns w/o a compiler.
I am actually checking on how to tackle such qns w/o a compiler.
makan007 wrote:
I am actually checking on how to tackle such qns w/o a compiler.


I don't understand this comment...
Liga7
Veronica26
tt40
tt47

How to get the above answers?
Was my answer not clear enough????
Hi Return 0

What I hope to have is step by step on how to get the answers when the main function runs.
I do not need to #include <string> header to compile the attached sourcecode.
Topic archived. No new replies allowed.