#ifndef SHAPEFACTORY_H_
#define SHAPEFACTORY_H_
#include <istream>
#include <map>
#include <string>
#include "shape.h"
typedef Shape *(createShapeFunction)(void);
/* thrown when a shape cannot be read from a stream */
class WrongFormatException { };
class ShapeFactory {
public:
static void registerFunction(const std::string &string, const createShapeFunction *shapeFunction);
static Shape *createShape(const std::string &string);
static Shape *createShape(std::istream &ins);
private:
std::map<std::string, createShapeFunction *> creationFunctions;
ShapeFactory();
static ShapeFactory *getShapeFactory();
};
#endif
這頭,我還沒有實現任何方法,但我正在以下警告:預選賽功能型..有明確的行爲
Qualifier on function type 'createShapeFunction' (aka 'Shape *()') has unspecified behavior
PS:這個頭球被給予我的老師和作爲功課我必須實施方法
您需要在第一組parens中有一顆星:'typedef Shape *(* createShapeFunction)(void);' – metal
就是這樣。謝謝! – Teodora
@metal,請你解釋一下爲什麼? – Teodora