I just started with class and I need help debugging.

I wrote this code and I cant figure out where it's all gone wrong. My complier says "ld returned 1 exit status"

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
  #include <iostream>

class Employee {

public:

	Employee(int age, int yearsOfService, int salary);
	~Employee() {};

	int GetAge() const { return itsAge; }
	int GetYearsOfService() const { return itsYearsOfService; }
	int GetSalary() const { return itsSalary; }

	float GetThousands() { return itsSalary / 1000; }

private:
	int itsAge;
	int itsYearsOfService;
	int itsSalary;
};



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include "Employee.hpp" 

Employee::Employee(int age, int yearsOfService, int salary) {
	itsAge = age;
 	itsYearsOfService = yearsOfService;
 	itsSalary = salary; 
}

int main() {

	Employee Ivan(54, 8, 11000);
	Employee Dorian(40, 4, 5500);

	std::cout << "Ivan's " << Ivan.GetAge() << " years old.\n";
	std::cout << "He has been working there for " << Ivan.GetYearsOfService() << " years,\n";
	std::cout << "but his salary is only " << Ivan.GetSalary() << "$.\n";
	std::cout << "and " << (Ivan.GetThousands() * 1000) * 12 << "$ a year.\n\n";

	std::cout << "Dorian's " << Dorian.GetAge() << "years old.\n";
	std::cout << "He has been working there for " << Dorian.GetYearsOfService() << " years,\n";
	std::cout << "but his salary is " << Dorian.GetSalary() << "$.\n\n";
}


Thanks!
Last edited on
Show your constructor definition. And do you link file where that definition is located?
Idk if this matters but shouldnt he remove #include <iostream> from his main function since it is already used in the Employee.hpp?
MiiNiPaa This is all of the code. What shoud I do?

coltehrman fixed
Last edited on
Well, apparently you need to define declared Employee(/*...*/) constructor
Thanks I did it and it works. I will update the code.

PS: I am learning c++ for I week.
Topic archived. No new replies allowed.