When I have a header file and an implementation file, if I write the main() function and I write the #include <header file.h> and #include <implementation file.h> I get a message that says: No such file or directory and the program terminates.
But if i put in all the three files in one big file, the program runs Okay.
..... and I write the #include <header file.h> and #include <implementation file.h> .....
yes they are in quotes and not in angle brackets.
Maybe you should post the whole of the code you have (don't forget the code tags - the <> button on the format menu), and any compiler messages verbatim.
These are example programs in Water Savitch C++ textbook.
We don't have that book, so it is difficult to provide help in that context.
//DISPLAY 15.7 Using Derived Classes
#include <iostream>
#include "hourlyemployee.h"
#include "salariedemployee.h"
using std::cout;
using std::endl;
using namespace employeessavitch;
//using namespace std;
int main( )
{
HourlyEmployee joe;
joe.set_name("Mighty Joe");
joe.set_ssn("123-45-6789");
joe.set_rate(20.50);
joe.set_hours(40);
cout << "Check for " << joe.get_name( )
<< " for " << joe.get_hours( ) << " hours.\n";
joe.print_check( );
cout << endl;
SalariedEmployee boss("Mr. Big Shot", "987-65-4321", 10500.50);
cout << "Check for " << boss.get_name( ) << endl;
boss.print_check( );
return 0;
}
Here is the header file:
//DISPLAY 15.1 Interface for the Base Class Employee
//This is the header file employee.h.
//This is the interface for the class Employee.
//This is primarily intended to be used as a base class to derive
//classes for different kinds of employees.
#ifndef EMPLOYEE_H
#define EMPLOYEE_H
3 28 E:\Savichexamples\SourceCode\Chapter15\15-07.cpp [Error] hourlyemployee.h: No such file or directory
compilation terminated.
From 15-01 to 15-06 are the headers files and the inplementation files.
I did not post all of them. I only posted 15-01 and 15-07 which is the main program.
Please edit your post and add code tags. Highlight the contents of the file in your post and click the button that looks like "<>". That will make it easier to comment on your code.
That being said, from the comments it looks like your header file is named "employee.h", but in 15-07.cpp you are trying to include "hourlyemployee,h"
//DISPLAY 15.3 Interface for the Derived Class HourlyEmployee
//This is the header file hourlyemployee.h.
//This is the interface for the class HourlyEmployee.
#ifndef HOURLYEMPLOYEE_H
#define HOURLYEMPLOYEE_H