C++: invalid use of incomplete type - c++

First of all I want to apologize for my english. I'm afraid that is not my born language. I'm going crazy with this code.
I'm making a little engine to make games. I implemented a class called "process" that is the class that will inherit all the elements that make up the game. What happens is that by implementing two of these elements so that inherit from "process" the compiler throws me the following error:
||=== Build: Debug in MotorSDL (compiler: GNU GCC Compiler) ===|
include/mainProcess.h |6 | error: invalid use of incomplete type ‘class process’
include/declarativas.h |65| error: forward declaration of ‘class process’
include/exeControl.h |6 | error: invalid use of incomplete type ‘class process’
include/declarativas.h |65| error: forward declaration of ‘class process’
/home/yawin/Dokumentuak/c/MotorSDL/src/engine.cpp | | In destructor ‘virtual Engine::~Engine()’:
/home/yawin/Dokumentuak/c/MotorSDL/src/engine.cpp |11| warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/home/yawin/Dokumentuak/c/MotorSDL/src/engine.cpp | | In member function ‘void Engine::update()’:
/home/yawin/Dokumentuak/c/MotorSDL/src/engine.cpp |76| warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
||=== Build failed: 4 error(s), 2 warning(s) (0 minute(s), 0 second(s)) ===|
I have read many of the issues in this respect have been published on this forum before and I understand that the mistake is that I am not correctly using a class (the class "process") because not instantiate properly or because it lacks something to the class (a required method not implemented).
But as I read and check my code I can't find where I'm making the mistake. Is anyone able to see what I'm wrong?
Here is the source code:
https://github.com/yawin123/SDLEngine
"main.cpp"
#include <SDL2/SDL.h>
#include "declarativas.h"
int main()
{
Engine *e = new Engine(true);
e->newWindow("Hola mundo", SDL_WINDOW_OPENGL, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, SDL_RENDERER_ACCELERATED);
e->newTask(new exeControl());
do
{
e->run();
SDL_Delay(1);
}while(e->isRunning());
e->destroyWindow();
return 0;
}
"include/declarativas.h"
#ifndef DECLARATIVAS_H
#define DECLARATIVAS_H
enum keyCode
{
_esc,
_1, _2, _3, _4, _5, _6, _7, _8, _9, _0,
_minus, _plus,
_backspace,
_tab,
_q, _w, _e, _r, _t, _y, _u, _i, _o, _p,
_a, _s, _d, _f, _g, _h, _j, _k, _l,
_z, _x, _c, _v, _b, _n, _m,
_f1, _f2, _f3, _f4, _f5, _f6, _f7, _f8, _f9, _f10, _f11, _f12,
_enter,
_c_enter,
_control,
_l_shift,
_comma,
_point,
_r_shift,
_c_asterisk,
_prn_scr,
_alt,
_caps_lock,
_num_lock,
_scroll_lock,
_home,
_c_home,
_up,
_c_up,
_pgup,
_c_minus,
_left,
_c_left,
_c_center,
_right,
_c_right,
_c_plus,
_end,
_c_end,
_down,
_c_down,
_pgdn,
_c_pgdn,
_ins,
_c_ins,
_del,
_c_del,
_less,
_equals,
_greater,
_asterisk,
_r_alt,
_r_control,
_l_alt,
_menu,
_l_windows,
_r_windows,
_close_window,
_FOO_KEY
};
class Engine;
class process;
class Ventana;
//Procesos
class mainProcess;
class exeControl;
#include "process.h"
#include "engine.h"
#include "Ventana.h"
#include "mainProcess.h"
#include "exeControl.h"
#endif // DECLARATIVAS_H
"include/process.h"
#ifndef PROCESS_H
#define PROCESS_H
#include "engine.h"
#include "declarativas.h"
class process
{
public:
process();
process(Engine *e);
virtual ~process();
virtual void Update();
int id;
int father;
void setEngine(Engine *e);
protected:
Engine *engine;
};
#endif // PROCESS_H
"src/process.cpp"
#include "process.h"
process::process(){return;}
process::process(Engine *e)
{
setEngine(e);
}
process::~process()
{
return;
}
void process::setEngine(Engine *e)
{
engine=e;
}
void engine::Update()
{
return;
}
"include/engine.h"
#ifndef ENGINE_H
#define ENGINE_H
#include "Ventana.h"
#include "process.h"
#include "declarativas.h"
#include <SDL2/SDL.h>
#include <vector>
#include <iostream>
using namespace std;
class Engine
{
public:
Engine(bool debug=false);
virtual ~Engine();
void run();
void newWindow(string i_title, int i_windowMode, int i_posX, int i_posY, int i_width, int i_height, int i_rendererMode);
void destroyWindow();
Ventana* ventana;
/**Ciclo de ejecución**/
void input();
void update();
void render();
/*********************/
/**Control de ejecución*******/
bool isRunning();
void isRunning(bool m_r);
bool m_run=true;
/*****************************/
vector<process*> taskManager; //Gestor de procesos
int newTask(process *task); //Dar de alta procesos
SDL_Event event; //Evento para controlar teclado
bool key[_FOO_KEY]; //Array de teclas pulsadas
/**Control de debug*******/
bool isDebug;
void Debug(string t);
void Debug(int t);
void Debug(float t);
/************************/
};
#endif // ENGINE_H
"src/engine.cpp"
#include "engine.h"
Engine::Engine(bool debug)
{
isDebug=debug;
SDL_Init(SDL_INIT_VIDEO);
}
Engine::~Engine()
{
for(int i=0;i<taskManager.size();i++)
{
delete(taskManager[i]);
}
taskManager.clear();
delete(ventana);
SDL_Quit();
}
void Engine::newWindow(string title, int windowMode, int posX, int posY, int width, int height, int rendererMode)
{
if(ventana)
{
destroyWindow();
}
ventana = new Ventana(title,windowMode,posX,posY,width,height,rendererMode);
}
void Engine::destroyWindow()
{
delete(ventana);
}
void Engine::run()
{
input();
update();
render();
}
void Engine::input()
{
for(int i=0;i<_FOO_KEY;i++)
{
key[i]=false;
}
while (SDL_PollEvent(&event))
{
switch (event.type)
{
case SDL_QUIT: //Si pulsamos el botón de cerrar ventana
key[_close_window]=true;
break;
case SDL_KEYDOWN:
switch (event.key.keysym.sym)
{
case SDLK_ESCAPE:
key[_esc]=true;
break;
default:
break;
}
break;
default:
break;
}
}
}
void Engine::update()
{
for(int i=0;i<taskManager.size();i++)
{
taskManager[i]->Update();
}
}
void Engine::render()
{
ventana->render();
}
bool Engine::isRunning()
{
return m_run;
}
void Engine::isRunning(bool m_r)
{
m_run=m_r;
}
int Engine::newTask(process *task)
{
taskManager.push_back(task);
taskManager[taskManager.size()-1]->setEngine(this);
return taskManager.size()-1;
}
void Engine::Debug(string t)
{
if(isDebug)
cout<<t<<endl;
}
void Engine::Debug(int t)
{
if(isDebug)
cout<<t<<endl;
}
void Engine::Debug(float t)
{
if(isDebug)
cout<<t<<endl;
}
"include/mainProcess.h"
#ifndef MAINPROCESS_H
#define MAINPROCESS_H
#include "process.h"
class mainProcess : public process
{
public:
mainProcess();
virtual ~mainProcess();
virtual void Update();
};
#endif // MAINPROCESS_H
"src/mainProcess.cpp"
#include "mainProcess.h"
mainProcess():process(){}
mainProcess::~mainProcess(){}
void mainProcess::Update()
{
return;
}
"include/exeControl.h"
#ifndef EXECONTROL_H
#define EXECONTROL_H
#include "process.h"
class exeControl : public process
{
public:
exeControl();
virtual ~exeControl();
virtual void Update();
};
#endif // EXECONTROL_H
"src/exeControl.cpp"
#include "exeControl.h"
exeControl::exeControl():process(){}
exeControl::~exeControl(){}
void exeControl::Update()
{
if(engine->key[_esc] || engine->key[_close_window])
{
engine->isRunning(false);
}
}
I think you don't need the rest of the classes. But if you need, you can find in the link to github above.

You have a circular inclusion issue.
process.h includes engine.h and engine.h includes process.h. You need to break this cycle. This is usually done with using forward declarations and pushing includes in the the source files.
At a quick glance it looks like you can do a forward declaration of process in engine.h and remove the include.
Note: Often you include a header in the header file of a class and in the source file of the same class but it's not necessary in the header already includes it.
Example Issue
Foo.h
#ifndef FOO_H
#define FOO_H
#include "Bar.h"
class Foo
{
private:
Bar* mBar; // Raw pointer should actually be an appropriate smart pointer type
};
#endif
Foo.cpp
// Nothing required here for this example
Bar.h
#ifndef BAR_H
#define BAR_H
#include "Foo.h"
class Bar
{
private:
Foo mFoo;
};
#endif
Bar.cpp
// Nothing required here for this example
In the above there is a circular inclusion issue; the include guards have nothing to do with fixing this issue. Furthermore, since Foo only uses a pointer to a Bar instance a forward declaration can be used to break the cycle.
Example Solution
Foo.h
#ifndef FOO_H
#define FOO_H
// Note: #include "Bar.h" is removed
class Bar; // This forward declares the `Bar` class
class Foo
{
private:
Bar* mBar; // Raw pointer should actually be an appropriate smart pointer type
};
#endif
Foo.cpp
#include "Bar.h"
Bar.h
#ifndef BAR_H
#define BAR_H
#include "Foo.h"
class Bar
{
private:
Foo mFoo;
};
#endif
Bar.cpp
// Nothing required here for this example

You have a case of cyclic dependency here: Engine class uses process and process uses Engine. This is often an indicator of a flawed architecture.
If all you care for is resolving the compilation issue, forward declaration should do the trick: remove either "process.h" from "engine.h" (or vice versa) and declare
class process;
in the "engine.h" header.

Related

C++ Class inheritance in different files

I'm trying to learn Inheritance mechanism in C++, I have made a Bancnote(Bills) class, and I want to make a class Card inheriting all the functions and variables from Class Bancnote.
And I get this type of error :
include\Card.h|6|error: expected class-name before '{' token|
BANCNOTE.H
#ifndef BANCNOTE_H
#define BANCNOTE_H
#include <iostream>
#include "Card.h"
using namespace std;
class Bancnote
{
public:
Bancnote();
Bancnote(string, int ,int ,int );
~Bancnote( );
int getsumacash( );
void setsumacash( int );
int getsumaplata( );
void setsumaplata( int );
int getrest( );
void setrest( int );
string getnume( );
void setnume( string );
void ToString();
protected:
private:
string nume;
int sumacash;
int rest;
static int sumaplata;
};
#endif // BANCNOTE_H
BANCNOTE.CPP
#include <iostream>
#include "Bancnote.h"
#include "Card.h"
using namespace std;
int Bancnote::sumaplata=0;
Bancnote::Bancnote(string _nume,int _sumacash,int _rest, int _sumaplata )
{
this->nume=_nume;
this->sumacash=_sumacash;
this->rest=_rest;
this->sumaplata=_sumaplata;
}
Bancnote::Bancnote()
{
this->nume="";
this->sumacash=0;
this->rest=0;
this->sumaplata=0;
}
Bancnote::~Bancnote()
{
cout<<"Obiectul"<<"->" <<this->nume<<"<-"<<"a fost sters cu succes";
}
string Bancnote::getnume()
{
return nume;
}
void Bancnote::setnume(string _nume)
{
this->nume=_nume;
}
int Bancnote::getsumacash()
{
return sumacash;
}
void Bancnote::setsumacash(int _sumacash)
{
this->sumacash=_sumacash;
}
int Bancnote::getsumaplata()
{
return sumaplata;
}
void Bancnote::setsumaplata(int _sumaplata)
{
this->sumaplata=_sumaplata;
}
int Bancnote::getrest()
{
return rest;
}
void Bancnote::setrest(int _rest)
{
this->rest=_rest;
}
void Bancnote::ToString()
{
cout<< "-----"<<getnume()<< "-----"<<endl;
cout<<"Suma Cash: "<<this->getsumacash()<<endl;
cout<<"Suma spre plata: "<<this->getsumaplata()<<endl;
cout<<"Restul:"<<this->getrest()<<endl;
}
CARD.H
#ifndef CARD_H
#define CARD_H
#include "Bancnote.h"
class Card: public Bancnote
{
public:
Card();
virtual ~Card();
protected:
private:
};
#endif // CARD_H
You have messed up the includes. What you have is more or less this:
Bancnote.h:
#ifndef BANCNOTE_H
#define BANCNOTE_H
#include "Card.h" // remove this
struct Bancnote {};
#endif
Card.h
#ifndef CARD_H
#define CARD_H
#include "Bancnote.h"
struct Card : Bancnote {}; // Bancnote is not yet declared
// when compiler reaches here
#endif
When in main you include Bancnote.h then this header includes Card.h so you try to declare Card before Bancnote is declared. Actually Bancnote does not need the definition of Card, so simply removing the include should fix it.
PS: there are other issues (see comments below your question). Most importantly it is not clear why a Card is a Bancnote. Second, never put a using namespace std; inside a header! (see here why)

VC++ undeclared identifier

Why this in Client.cpp file I'm getting error C2065:'TunnelContainer': undefined identifier?
Client.cpp code:
#include "stdafx.h"
#include "GClientLib.h"
using namespace GClientLib;
int _tmain(int argc, _TCHAR* argv[])
{
SettingsReader^ settings = gcnew SettingsReader();
SocketToObjectContainer^ STOContainer = gcnew SocketToObjectContainer();
TunnelContainer^ tunnels = gcnew TunnelContainer();
timeval time;
time.tv_sec = 0;
time.tv_usec = 300000;
....
GClientLib.h code fragment:
#include "Structures.h"
#include "Globals.h"
#include "SettingsReader.h"
#include "SocketToObjectContainer.h"
#include "SocketToSocketContainer.h"
#include "TunnelContainer.h"
Updated. SocketToSocketContainer.h
#ifndef SocketToSocketContainer_H
#define SocketToSocketContainer_H
#include <cliext/utility>
#include <cliext/list>
#include <cliext/algorithm>
namespace GClientLib {
ref class SocketToSocketContainer {
private:
cliext::list<cliext::pair<int, int>> sarasas;
public:
SocketToSocketContainer(void);
void Add(int, int);
int Find(int);
void Delete(int);
};
};
#endif
GclientLib is lib project, used in Client application. Build on Visual Studio 2013 C++/CLI enabled
TunnelContainer.h code:
#ifndef GClientLib_H
#define GClientLib_H
#include <cliext/utility>
#include <cliext/list>
#include <cliext/algorithm>
namespace GClientLib {
enum TunnelStatus
{
JUNGIASI = 1, //Uzmezgamas rysys tarp klientu
LAUKIA_PROGRAMOS = 2, // Laukia kol prisijungs norima kliento porgramine iranga
KOMUNIKACIJA = 3 // Tuneliu vyksta komunikacija
};
ref struct Tunnel
{
int tag; //Tunelio zyme
int dport; //Prievadas, prie kurio jungesi
int clientid; //Kliento ID su kuriuo sujungta
int sport; //Vietinis prievadas
int serverSocket; //Socketas, prie kuris priima duomenu srauta
int status; // Sujungimo statusas (Jungiasi, prisjungta, laukia jungties)
};
ref class TunnelContainer {
private:
// Tuneliu sarasas
cliext::list<cliext::pair<int, Tunnel^>> sarasas;
public:
// Konstruktorius
TunnelContainer();
// Pridedamas naujas tunelis. PERRASO statusa i JUNGIAMASI
Tunnel^ Add(Tunnel^ tunelis);
// Pridedamas naujas tunelis. Statusa nustato i JUNGIAMASI
Tunnel^ Add(int tag, int dport, int clientid, int sport, int serverSocket);
// Tunelio paieska pagal tag
Tunnel^ Find(int tag);
// Salina tuneli pagal tag
Tunnel^ Remove(int tag);
// Keicia tunelio statusa
void ChangeStatus(int tag, TunnelStatus status);
};
};
#endif
UPDATE
After moving TunnelContainer.h into first position getting this error in ToServerSocket.h file:
Error 1 error C2143: syntax error : missing ';' before '^' line 16
Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int line 16
ToServerSocket.h code:
#ifndef ToServerSocket_H
#define ToServerSocket_H
#include <iostream>
#include "gNetSocket.h"
#include "ServerSocket.h"
#include "OutboundSocket.h"
namespace GClientLib {
ref class ToServerSocket : public gNetSocket {
private:
char *commandBuffer;
line 16 --->TagGenerator^ tag;
SocketToObjectContainer^ STOC;
SettingsReader^ settings;
public:
ToServerSocket(string ip, string port, fd_set* skaitomiSocket, fd_set* rasomiSocket, fd_set* klaidingiSocket, SocketToObjectContainer^ STOC, SettingsReader^ settings);
virtual int Send(char* data, int lenght) override;
virtual void Recive(SocketToObjectContainer^ container) override;
virtual void Connect() override;
virtual void Reconnect() override;
void CommandList(int page);
void CommandListAck(int rRecv);
void CommandHello();
void CommandHelp();
void CommandInitConnect(int id, int port, SocketToObjectContainer^ container);
void CommandConnect(SocketToObjectContainer^ container);
void CommandClear();
void CommandBeginRead(SocketToObjectContainer^ container);
void CommandClientConnectAck(SocketToObjectContainer^ container);
void CommandInitConnectAck();
void CommandJsonList(int page, SOCKET socket);
void CommandJsonListAck(int rRecv, SocketToObjectContainer^ container);
void CommandJsonInitConnect(int id, int port, SOCKET socket);
void CommandJSONConnect(SocketToObjectContainer^ container);
void CommandJsonInitConnectAck();
int GenerateTag();
};
};
#endif
you probably have a syntax error or missing ; or missing closing " in the include before that, "SocketToSocketContainer.h".
#include is a precompiler statement, all it does is include the content of the given file into the main file; it is your task to make sure that the result is a valid code. So if one include has an incomplete statement, the content of the second include continues that statement.
Edit: It could be even further up in the list - any open or incorrect #IFDEF in any include could remove the whole rest
I have found my mistake. GClientLib_H was already defined.
#ifndef GClientLib_H
#define GClientLib_H
Changed to
#ifndef TunnelContainer_H
#define TunnelContainer_H
Now everything is working. Thank you for quick responses

C++ class name does not name a type

#ifndef MAIN_H_INCLUDED
#define MAIN_H_INCLUDED
#include "Setup.h"
#include "mainCharacter.h"
class Main {
public:
Main(int pScreenWidth, int pScreenHeight);
~Main();
void gameLoop();
private:
bool quit;
Setup* setup;
mainCharacter* tom;
int screenWidth;
int screenHeight;
int mouseX;
int mouseY;
};
#endif // MAIN_H_INCLUDED
I saw the other topics on this, but the error im getting is not of the same type, how can it tell me that
Setup* setup;
mainCharacter* tom;
does not name a type when the includes are above ?
im using code::blocks if that matters.
EDIT://////////////////////
This is the Setup header:
#ifndef SETUP_H_INCLUDED
#define SETUP_H_INCLUDED
#include <SDL.h>
#include <SDL_image.h>
#include <SDL_mixer.h>
#include "Main.h"
#include "Sprite.h"
class Setup {
public:
Setup(int screenWidth, int screenHeight);
~Setup();
SDL_Renderer* getRenderer();
SDL_Event* getEvent();
private:
SDL_Window* window;
SDL_Renderer* renderer;
SDL_Event* event;
};
#endif // SETUP_H_INCLUDED
and this is the mainCharacter header:
#ifndef MAINCHARACTER_H_INCLUDED
#define MAINCHARACTER_H_INCLUDED
#include "Sprite.h"
#include "Setup.h"
#include <cmath>
class mainCharacter {
public:
mainCharacter(Setup* pSetup, int* pMouseX, int* pMouseY);
~mainCharacter();
double getDistance(int x1, int y1, int x2, int y2);
void update();
void draw();
private:
Sprite* shagy;
///some variables are here/////
Setup* setup;
};
#endif // MAINCHARACTER_H_INCLUDED
there are Setup.cpp and mainCharacter.cpp files and they got a long code written on them, the only thing i inclue in setup.cpp is setup.h and maincharacter.cpp i only include maincharacter.h
#ifndef SETUP_H_INCLUDED
#define SETUP_H_INCLUDED
Make sure you aren't defining SETUP_H_INCLUDED somewhere else, this is the only reason i see.
Also it's possible that your %INCLUDE% (include directories) has another Setup.h somewhere, which does not define Setup class, and your Setup.h is not loaded.

c++ Inheritance in different files error

For some reason I can't manage to figure out what is wrong with my inheritance in c++ within different files. The biggest error I get is 'no matching function for call to 'Enemy::Enemy (int&)'
Here is my Monster.cpp code
#include "Monster.h"
#include "Enemy.h"
#include <iostream>
Monster::Monster(int MonsterHealth,int MonsterMana,int Monstersize) // implementation
: Health(MonsterHealth), Mana(MonsterMana), Enemy(Monstersize)
{}
int Monster::dropxp(int enemydropxp){
}
Here is my Monster.h
#ifndef MONSTER_H
#define MONSTER_H
#include "Enemy.h"
class Monster : public Enemy
{
Monster();
Monster(int MonsterHealth, int MonsterMana,int Monstersize);
void TheenemyHealth()
{
int Enemyhealth = 100;
}
int EnemyDamage(int EnemyAttack){
int Attack = EnemyAttack;
Attack = 5;
}
int dropxp(int enemyxpdrop);
private:
int Health = 0;
int Mana = 0;
};
#endif // MONSTER_H
Here is my enemy.cpp
#include "Enemy.h"
Enemy::Enemy(int EnemyHealth,int EnemyMana)
{
Attackpower;
Strenght;
Enemyxp;
}
Enemy::~Enemy()
{
//dtor
}
and my enemy.h
#ifndef ENEMY_H
#define ENEMY_H
class Enemy
{
public:
Enemy(int EnemyHealth,int EnemyMana);
~Enemy();
virtual void TheenemyHealth(){}
virtual int EnemyDamage(int EnemyAttack){
int Attack = EnemyAttack;
}
virtual int dropxp(int enemyxpdrop);
private:
int Attackpower= 0;
int Strenght = 0;
int Enemyxp= 0;
};
#endif // ENEMY_H
Your enemy constructor is defined as Enemy(int EnemyHealth,int EnemyMana); but you are calling it with only one parameter in:
Monster::Monster(int MonsterHealth,int MonsterMana,int Monstersize) // implementation
: Health(MonsterHealth), Mana(MonsterMana), Enemy(Monstersize)
{}
Also your Enemy constructor does nothing:
Enemy::Enemy(int EnemyHealth,int EnemyMana)
{
Attackpower; // does nothing
Strenght; // does nothing
Enemyxp; // does nothing
}

cannot instantiate abstract class but class isn't abstract

I've looked this up and the closest thing I found was this except I don't have any forward declarations. I only have one pure virtual function in the base class which I'm implementing in the subclass as follows:
Command.h
#ifndef _COMMAND_H_
#define _COMMAND_H_
#include <string>
#include "Stack.h"
#include "Number.h"
class Command
{
public:
std::string cmdType;
Command(void);
Command (std::string cmdType);
virtual void executeCommand(Stack<Number> & stack) = 0;
~Command (void);
};
#endif // !defined _COMMAND_H_
Command.cpp
Command::Command(void)
:cmdType("")
{}
Command::Command(std::string cmdType)
:cmdType(cmdType)
{}
Command::~Command(void)
{}
Number.h
#ifndef _NUMBER_H_
#define _NUMBER_H_
#include "Command.h"
#include "Stack.h"
class Number : public Command
{
public:
Number (float num);
void executeCommand(Stack<Number> & stack);
float val;
~Number (void);
};
#endif // !defined _NUMBER_H_
Number.cpp
#include "Number.h"
Number::Number(float num)
:val(num)
{
cmdType = "hi";
}
void Number::executeCommand(Stack<Number> & stack)
{
stack.push((*this));
}
File error occurs:
Error 4 error C2259: 'Number' : cannot instantiate abstract class c:\...\add.cpp 34
Add.cpp
#include "Add.h"
Add::Add(void)
:Binary("+")
{
}
Add::~Add(void)
{
}
void Add::executeCommand(Stack<Number> & numStack)
{
Number num1 = numStack.top(); //THIS LINE HAS THE ERROR
numStack.pop();
Number num2 = numStack.top();
numStack.pop();
float tempVal = num2.val + num1.val;
num1.val = tempVal;
numStack.push(num1);
}
Add.h
#ifndef _ADD_H_
#define _ADD_H_
#include "Stack.h"
#include "Number.h"
#include "Binary.h"
class Add : public Binary
{
public:
Add (void);
void executeCommand (Stack<Number> & numStack);
~Add (void);
};
#endif // !defined _ADD_H_
This is a circular dependency problem.
Command.h includes Number.h
Number.h includes Command.h
Usually it is solved by replacing one of the includes with a forward declaration, try forward-declaring Number in Command.h instead of including Number.h; move that include to Command.cpp.