Static object in mfc, only one instance for all instance of my class
-
Hi, My Class is using some bitmap, there not very big I'd like that only one instance of the bitmap exist for all instance of my class. In java it's static member of the class, in MFC I've try to do Class MyClass: public CWnd { ...blablabla... private: static CBitmap MyBitmap; ...blablabla } and the linker said MyClass.obj :error LNK2001:unresolved external symbol "private: static class CBitmap MyClass::MyBitmap" (?MyBitmap@MyClass@@0VCBitmap@@A) so what is wrong? Remi Morin Rmorin@Operamail.com Remi.Morin@Lyrtech.com
-
Hi, My Class is using some bitmap, there not very big I'd like that only one instance of the bitmap exist for all instance of my class. In java it's static member of the class, in MFC I've try to do Class MyClass: public CWnd { ...blablabla... private: static CBitmap MyBitmap; ...blablabla } and the linker said MyClass.obj :error LNK2001:unresolved external symbol "private: static class CBitmap MyClass::MyBitmap" (?MyBitmap@MyClass@@0VCBitmap@@A) so what is wrong? Remi Morin Rmorin@Operamail.com Remi.Morin@Lyrtech.com
in a .cpp file, you need to have:
#include "MyClass.h"
// declare the variable
CBitmap myClass::MyBitmap;-c ------------------------------ Smaller Animals Software, Inc. http://www.smalleranimals.com
-
in a .cpp file, you need to have:
#include "MyClass.h"
// declare the variable
CBitmap myClass::MyBitmap;-c ------------------------------ Smaller Animals Software, Inc. http://www.smalleranimals.com
thanks, it was easy;) Remi Morin Rmorin@Operamail.com Remi.Morin@Lyrtech.com