Reputation: 237
For class we are creating a class Sim that inherits from templated class Queue and then both are utilized in program p05. So far I am just trying to make sure that class Queue compiles and that there are no syntax errors in the interface of Sim. Queue is compiling fine. The implementation of sim is not written, just the class definition. They are all linked into p05 through a makefile, and I am receiving the following error:
~$ make -f p05make
g++ -c -g p05.cpp
In file included from p05.cpp:20:0:
Sim05.h:24:23: error: expected class-name before â{â token
make: *** [p05.o] Error 1
tt054@cs:~$
I am not sure why this is because I have included Queue05.h and the syntax of my class declaration is the same as the last time we did something similar.
Queue05.h
#ifndef Queue05_h
#define Queue05_h 1
//Queue05.h contains the interface for class Queue
#include <cstdlib>
#include <cstring>
#include <iostream>
template <class T>
class Queue {
//member data and functions omitted for length
};
#endif
Sim05.h
#ifndef Sim05_h
#define Sim05_h 1
#include <fstream>
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
#include "Queue05.h"
//next line is where error occurs
class Sim:public Queue{
//member data and functions omitted for length
};
#endif
Upvotes: 1
Views: 167