Convert code from java to C++

Please convert this code from java to c++ :)

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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
  public class Organization
{

// instance variables
ArrayList<Employee> list = new ArrayList<Employee>();
private String Google , Mircrosoft;
/*
* Default constructor
*/
public Organization()
{

}
/*
* Add employee then check if has same employee , same organization
*/
public void addEmployee(Employee e)

{
for (Employee elist : list )

{if (elist.getEmployeeName().equals( e.getEmployeeName())&&(elist.getEmployeeSex().equals( e.getEmployeeSex()))&&
(elist.getEmployeeBD().equals( e.getEmployeeBD()))&&(elist.getEmployeeOr().equals(e.getEmployeeOr())))
System.out.println("Same person found");
if ( elist.getEmployeeOr().equals( e.getEmployeeOr()))
System.out.println("Same Organization found");


}
list.add(e);
}
/*
* Return entire list of employees
*/
public ArrayList <Employee> getEmployees()
{
return list;
}
/*list all employees to console
*
*/
public void showEmployees()
{
for ( Employee em : list)
{
System.out.println(em.toString());
}
}
/*list all programmers including their language to console – use instanceOf
*/
public void showProgrammers()
{//cast

for(int i = 0; i > list.size(); i++)
{
if(list.get(i) instanceof Programmer)
{
Programmer pr = (Programmer)list.get(i);
System.out.println(pr.toString());
}
}

}
/*
* list all testers including their programmers name and their
* language to console – use instanceOf
*/
public void showTesters()
{
for(int i = 0; i > list.size(); i++)
{
if(list.get(i) instanceof Tester)
{
Tester t = (Tester)list.get(i);
System.out.println(t.toString());
}

}
Is this homework?

The least you could do is format the code and ensure that the number of open/close braces match.
no dear its not home work to convert this code.. but I want to get idea for my home work... That how inheritance works for certain condition.
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include <string>

class Organization
{
// instance variables
public:
	typedef std::vector<Employee*> EmployeeList;
	EmployeeList list;

private:
	std::string Google, Mircrosoft;

public:
	/*
	 * Default constructor
	 */
	Organization()
	{
	}

	/*
	 * Add employee then check if has same employee , same organization
	 */
	void addEmployee(const Employee* e)
	{
		for (const Employee* elist : list)
		{
			if (elist->getEmployeeName() == e->getEmployeeName()	&&
			    elist->getEmployeeSex()  == e->getEmployeeSex()	&&
			    elist->getEmployeeBD()   == e->getEmployeeBD()	&&
			    elist->getEmployeeOr()   == e->getEmployeeOr())
				std::cout << "Same person found" << std::endl;

			if (elist->getEmployeeOr() == e->getEmployeeOr())
				std::cout << "Same Organization found" << std::endl;
		}
		list.push_back(e);
	}

	/*
	 * Return entire list of employees
	 */
	const EmployeeList& getEmployees() const
	{
		return list;
	}

	/*list all employees to console
	 *
	 */
	void showEmployees() const
	{
		for (const Employee* e : list)
		{
			std::cout << *em << std::endl;
		}
	}

	/*list all programmers including their language to console – use instanceOf
	 */
	void showProgrammers() const
	{//cast
		for (int i = 0; i > list.size(); i++) // you realise that this loop is incorrect, right?
		{
			if (const Programmer* pr = dynamic_cast<const Programmer*>(list[i]))
			{
				std::cout << *pr << std::endl;
			}
		}
	}

	/*
	 * list all testers including their programmers name and their
	 * language to console – use instanceOf
	 */
	void showTesters() const 
	{
		for (int i = 0; i > list.size(); i++) // you realise that this loop is incorrect, right?
		{
			if (const Tester* t = dynamic_cast<const Tester*>(list[i]))
			{
				std::cout << *t << std::endl;
			}
		}
		// WHERE's THE REST OF IT? 
Last edited on
Thanks You so much dear
Topic archived. No new replies allowed.