Bonjour,
J'ai un probleme avec le code ci-dessous.Je recois le message d'erreur ci-dessous. D'avance merci pour votre aide.
Sphere369
Message d'erreur:
1>ConsoleFactory.cpp
1>c:\cpp2006\chapter14\shapepatterns\05_abstractfactory\shapefactory.hpp(21) : error C4430: spécificateur de type manquant - int est pris en compte par défaut. Remarque*: C++ ne prend pas en charge int par défaut
1>c:\cpp2006\chapter14\shapepatterns\05_abstractfactory\shapefactory.hpp(21) : warning C4183: 'ShapeFatory'*: type de retour manquant*; fonction membre retournant 'int' prise par défaut
ConsoleFactory.cpp :
ShapeFactory.hpp :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83 #include "ConsoleFactory.hpp" #include "Point.hpp" #include "Line.hpp" #include "Circle.hpp" ConsoleFactory::ConsoleFactory(): ShapeFactory() { // Default constructor } ConsoleFactory::ConsoleFactory(const ConsoleFactory& source): ShapeFactory(source) { // Copy constructor } ConsoleFactory::~ConsoleFactory() { // Destructor } Point* ConsoleFactory::CreatePoint() { // Create point double x, y; std::cout << "Creating a point" << std::endl; // Input point std::cout<<"Input x: "; std::cin>>x; std::cout<<"Input y: "; std::cin>>y; return new Point(x, y); } Line* ConsoleFactory::CreateLine() { // Create line double x1, x2, y1, y2; std::cout << "Creating a line" << std::endl; // Input start- and endpoint std::cout<<"Input x1: "; std::cin>>x1; std::cout<<"Input y1: "; std::cin>>y1; std::cout<<"Input x2: "; std::cin>>x2; std::cout<<"Input y2: "; std::cin>>y2; return new Line(Point(x1, y1), Point(x2, y2)); } Circle* ConsoleFactory::CreateCircle() { // Create circle double x, y, r; std::cout << "Creating a circle" << std::endl; // Input centerpoint and radius std::cout<<"Input x: "; std::cin>>x; std::cout<<"Input y: "; std::cin>>y; std::cout<<"Input radius: "; std::cin>>r; return new Circle(Point(x, y), r); } ConsoleFactory& ConsoleFactory::operator = (const ConsoleFactory& source) { // Assignment // Exit if same object if (this==&source) return *this; // Call base assignment ShapeFactory::operator = (source); return *this; }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 #ifndef ShapeFactory_hpp #define ShapeFactory_hpp #include "Shape.hpp" #include "Point.hpp" #include "Circle.hpp" #include "Line.hpp" class ShapeFactory { private: public: // Constructors and destructor ShapeFactory(); // Default constructor ShapeFatory(const ShapeFactory& source); // Copy constructor virtual ~ShapeFactory(); // Destructor virtual Point* CreatePoint() = 0; // Create a point virtual Circle* CreateCircle() = 0; // Create a circle virtual Line* CreateLine() = 0; // Create a line // Operators ShapeFactory& operator = (const ShapeFactory& source); }; #endif // ShapeFactory_hpp
ShapeFactory.cpp :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 #include "ShapeFactory.hpp" ShapeFactory::ShapeFactory() { // Default constructor } ShapeFactory::ShapeFatory(const ShapeFactory& source) { // Copy constructor } ShapeFactory::~ShapeFactory() { // Destructor } ShapeFactory& ShapeFactory::operator = (const ShapeFactory& source) { // Assignment return *this; }
Partager