Header Files

Hi guys.I have a problem about header files.I am working with big c++ book.
I don't understand where ccc_empl.h is or how do i add this file to my project.
I am working visual studio 2010.Please help?


My header file(department.h) contains
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
  #ifndef DEPARTMENT_H
#define DEPARTMENT_H

#include<string>
#include "ccc_empl.h"

using namespace std;



class Department
{
public:
		Department(string n);
	void set_receptionist(Employee* e);
	void set_secretary(Employee* e);
	void print() const;
private:
	string name;
	Employee* receptionist;
	Employee* secretary;
};
#endif 


my source file(department.cpp) contains
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

#include<iostream>
#include "department.h"

using namespace std;
Department::Department(string n)
{
	name=n;
	receptionist=NULL;
	secretary=NULL;
}
void Department::set_receptionist(Employee* e)
{
	receptionist=e;
}

void Department::set_secretary(Employee* e)
{
	secretary=e;
}
void Department::print() const
{
	cout <<"name:  " <<name << "\n"
		<< "receptionist";
	if (receptionist==NULL)
		cout <<"nONE";
	else
		cout << receptionist->get_name() << " "
		<< receptionist->get_salary();
	cout << "\nsecretary:  ";
	if (secretary==NULL)
		cout << "none";
	else if (secretary==receptionist)
		cout <<" same";
	else
		cout << secretary->get_name() << " "
		<< secretary->get_salary();
	cout << "\n";
}


my test.cpp file contains
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
#include<iostream>
#include<string>

#include "department.h"
#include "ccc_empl.h"


using namespace std;

int main()
{
	Department shipping("Shipping");
	Department qc("quality control");
	Employee* harry=new Employee("Hacker,Harry", 45000);
	shipping.set_receptionist(harry);
	Employee* tina=new Employee("Hacker,Harry", 50000);
	qc.set_receptionist(tina);
	qc.set_secretary(tina);
	tina->set_salary(55000);
	shipping.print();
	qc.print();
	delete tina;
	delete harry;
	return 0;
}


I am working with big c++ book. I don't understand where ccc_empl.h is

In the book? A quick websearch with that filename hints that it is used in several examples of the book. If so, it is either printed in the book or included with the book.

MSVS is an IDE. IDE's tend to have concept "project" and allow one to create new or add existing file to projects. How an IDE is used is beyond my comprehension, but I presume they have documentation.

Visual Studio 2010 is getting old, because newer versions are available without charge and have more features and language support too.


Style notes on the code that you do show:

department.h:
* Replace line 5 with class Employee; A forward declaration is enough, because the header does not need more information.

* Replace line 7 with using std::string; There is no reason to expose the entire std here.

department.cpp:
* Add #include "ccc_empl.h" for this source has to know the Employee.

* Replace line 5 with
1
2
using std::string;
using std::cout;

* Constructors can and should use initializer list:
1
2
3
4
Department::Department(string n)
 : name(n), receptionist(NULL), secretary(NULL)
{
}


test.cpp:
* Remove lines 1, 2, 8. None of those are used in this file.
I just did a quick Google search for ccc_empl.h and the top result was a link to the file
on UCLA math Department website.
Thank you very much for your answers..I add cc_empl.h file to my project.It doesn't work but after that I add ccc_empl.cpp and finally project works.Again tahnk you for helps

Last edited on
Topic archived. No new replies allowed.