I have 5 files Clock.cc Clock1.cc Clock.h Clock1.h and Main.cc
Clock1 inherits from Clock.
I have tried to compile my program in Borland and it works nicely (but as one file Clock.cpp not as a project of multiple files).
But when I try to compile my files in G++ ; I break them up into seperate files like clock.h clock1.h etc. it gives me so many errors. I know I have not typed the header part of each file correctly. Could anyone please have a look and let me know please.
Code:
**Main.CC**
#include<iostream>
#include "Clock.h"
#include "Clock1.h"
using namespace std;
int main()
{
int hours, mins, secs;
char amPM; //To store whether AM or PM
Clock c; //Object creation of class Clock.
int stop; //To store temporary user input.
Clock *p1, *p2, *p3, *p4, *p5; //Set Clock objects which are pointers
Clock1 ny, lon, sing, cape, syd; //Set Zonal clocks for each city
...
}
**Clock.cc**
#include<iostream>
#include<time.h>
#include "Clock.h"
using namespace std;
Clock :: Clock()
{
hh = mm = ss = 0;
timerSecs = 0;
}
...
**Clock.h**
#ifndef CLOCK_H
#define CLOCK_H
class Clock{
protected:
int hh, mm, ss;
...
}
**Clock1.cc**
#include<iostream>
#include "Clock1.h"
#include "Clock.h"
using namespace std;
Clock1 :: Clock1 //Constructor
{
}
...
**Clock1.h**
#ifndef CLOCK_H
#define CLOCK_H
#include "Clock.h"
class Clock1 : public Clock //for zonal clocks
{
public:
...
I have only included the top bits because I feel sure that nothing is wrong with the program as it compiles fine in Borland under Windows.
Any suggestions or help will be greatly appreciated. I am new at this!
Thanks
Code tags added by kermi3