Shape.h
#include"圆环。"
#include"广场"
class Shape {
public:
virtual void Draw() = 0;
static Shape* Create(std::string type);
};
Shape.cpp
#include "Shape.h"
Shape* Shape::Create(string type) {
if ( type == "circle" ) return new Circle();
if ( type == "square" ) return new Square();
return NULL;
}
圆环。
#include "圆环。"
void Circle::Draw() {
cout << "I am circle" << endl;
}
圆环。
#include"Shape.h"
class Circle:public Shape {
public:
void Draw();
friend class Shape;
};
广场。
#include "广场"
void Square::Draw() {
cout << "I am Square" << endl;
}
广场
#include"Shape.h"
class Square:public Shape {
public:
void Draw();
friend class Shape;
};
It throws this error: 广场 error: expected class-name before { token [for the inheritance it does not identify Shape]
But the same code works if it is in a monolithic file(without the .cpp and .h) a single main.cpp file What is that I am missing with including header files?
预付款。