I have a superclass Letter.h
#ifndef LETTER_H //I have tried ifdef but it give me list of undefined reference
and variables out of scope
#define LETTER_H
#include "A.h"
using namespace std;
class Letter{
//variables are declared in protected
public:
Letter();
Letter(string,bool);
};
#endif
I have a sub class A.h
#ifndef A_H
#define A_H
#include "Letter.h"
using namespace std;
class A: public Letter{
//variables are declared in private
public:
A();
A(string, bool, int, int, double);
};
#endif
In my Letter.cpp I have #include Letter.h
In my A.cpp I have #include A.h
and #include Letter.h
In my A.cpp
A::A(string ShapeName, bool warpspace, int xval, int yval, double areas):Letter(ShapeName, warpspace)
{
xVal = xval;
yVal = yval;
area = areas;
}
In my letter.cpp
Letter::Letter (string name, bool containsWarpSpace)
{
this->name = name;
this->containsWarpSpace = containsWarpSpace;
}
when I compile the above like this: g++ Letter.cpp Letter.h A.cpp A.h it gives me error: expected class-name before ‘{’ token {
I know letter is the parent class it does not need to include the sub class but however when I remove the #include square.h it gives me relocation invalid symbol index error .
Is the guard and header files properly included this way?
Lets say if i haven't wrote anything to inherit from Letter yet , will the compiler still allow me to compile?