Click here to Skip to main content
15,914,943 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: landscape print in dialog? Pin
JockeP19-Jun-03 7:24
JockeP19-Jun-03 7:24 
GeneralColor picker Pin
chris!16-Jun-03 16:52
chris!16-Jun-03 16:52 
GeneralActiveX control---listview control 6.0 Pin
gucy16-Jun-03 16:47
gucy16-Jun-03 16:47 
Questiontabbed explorer where i can get it? Pin
david_joung16-Jun-03 15:33
david_joung16-Jun-03 15:33 
Generalwizard 98 help Pin
snipes16-Jun-03 12:45
snipes16-Jun-03 12:45 
GeneralCOM problem Pin
Joel Holdsworth16-Jun-03 12:18
Joel Holdsworth16-Jun-03 12:18 
GeneralRe: COM problem Pin
valikac16-Jun-03 13:20
valikac16-Jun-03 13:20 
Generalcdecl question Pin
Anonymous16-Jun-03 12:14
Anonymous16-Jun-03 12:14 
I have been going through the book Modern C++ Design. Obviously, since it is using generic programming alot of doesn't work on VC6, but I was curious about the following error when working with Object Factory example..

I have a class defined as "Shape" and a method defined as :

Shape * CreateConcreteShape();

Now, I have a class, called ShapeFactory as following:

class ShapeFactory
{
public:
static ShapeFactory * Instance();


protected:


typedef Shape * (*CreateShapeCallback) ();
// Returns true if registeration was successful

typedef std::map <int, createshapecallback=""> CallbackMap;


ShapeFactory();
ShapeFactory(const ShapeFactory & );
ShapeFactory& operator=(const ShapeFactory&);


bool RegisterShape (int ShapeId, CreateShapeCallback CreateFn);
bool UnregisterShape(int ShapeId);

Shape * CreateShape(int ShapeId);

CallbackMap callbacks_;

private:

static ShapeFactory * m_pInstance;


~ShapeFactory(); // the destructor should not be called from outside

};

Now, I have a class Line that inherits from Shape and it contains the following:

class Line : public Shape
{
public:
Line();
virtual ~Line();

virtual Shape * CreateLine();
virtual void Draw() const;
virtual void Rotate(double angle);
virtual void Zoom (double zoomFactor) ;

private:

static ShapeFactory TheFactory;


};

When I try adding the CreateLine method of the Line class to the ObjectFactory as shown below, I get the following compile-time error:

Line::Line()
{
ShapeFactory * pShapeFactory = ShapeFactory::Instance();

if(pShapeFactory != 0)
pShapeFactory->RegisterShape(1, CreateLine());

}

Error:

error C2664: 'RegisterShape' : cannot convert parameter 2 from 'class Shape *' to 'class Shape *(__cdecl *)(void)'
There is no context in which this conversion is possible

How do I fix this problem?

thanks
GeneralRe: cdecl question Pin
Joel Holdsworth16-Jun-03 12:30
Joel Holdsworth16-Jun-03 12:30 
GeneralIS That a class or function that detect if user is connected to the internet!! Pin
snipes16-Jun-03 11:30
snipes16-Jun-03 11:30 
GeneralRe: IS That a class or function that detect if user is connected to the internet!! Pin
Toni7816-Jun-03 19:53
Toni7816-Jun-03 19:53 
QuestionGet current tab position in a dialog box??? Pin
skinnyreptile16-Jun-03 11:16
skinnyreptile16-Jun-03 11:16 
AnswerRe: Get current tab position in a dialog box??? Pin
AlexO16-Jun-03 11:23
AlexO16-Jun-03 11:23 
AnswerRe: Get current tab position in a dialog box??? Pin
Ryan Binns16-Jun-03 15:04
Ryan Binns16-Jun-03 15:04 
GeneralRe: Get current tab position in a dialog box??? Pin
skinnyreptile17-Jun-03 3:27
skinnyreptile17-Jun-03 3:27 
GeneralRe: Get current tab position in a dialog box??? Pin
Ryan Binns17-Jun-03 3:56
Ryan Binns17-Jun-03 3:56 
Generalpassing a vector to a function Pin
johnstonsk16-Jun-03 9:39
johnstonsk16-Jun-03 9:39 
GeneralRe: passing a vector to a function Pin
Nemanja Trifunovic16-Jun-03 9:43
Nemanja Trifunovic16-Jun-03 9:43 
GeneralRe: passing a vector to a function Pin
johnstonsk16-Jun-03 9:51
johnstonsk16-Jun-03 9:51 
GeneralRe: passing a vector to a function Pin
AlexO16-Jun-03 9:55
AlexO16-Jun-03 9:55 
GeneralRe: passing a vector to a function Pin
AlexO16-Jun-03 9:59
AlexO16-Jun-03 9:59 
GeneralRe: passing a vector to a function Pin
johnstonsk16-Jun-03 10:00
johnstonsk16-Jun-03 10:00 
GeneralRe: passing a vector to a function Pin
AlexO16-Jun-03 10:05
AlexO16-Jun-03 10:05 
GeneralRe: passing a vector to a function Pin
johnstonsk16-Jun-03 10:12
johnstonsk16-Jun-03 10:12 
GeneralRe: passing a vector to a function Pin
johnstonsk16-Jun-03 9:53
johnstonsk16-Jun-03 9:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.