cranewhite
January 30th, 2001, 01:45 AM
in MFC, I can use
CRuntimeClass* pClass=RUNTIME_CLASS(CMyClass) ;
to get pClass,
then
pClass->CreateObject();
to do dynamic creation, but question:
It is not allowed to use a variable in RUNTIME_CLASS macro, so if I want to read in a string from a file, and the contents of this string is a class name, according to the class name in the string, i do dynamic creation, how should i do ?
Note: I donot want to do the following way:
read ClassName to str
if (str == "Class1")
new Class1;
else if (str == "Class2")
new Class2;
else if (str == "Class3")
new Class3;
else if (str == "Class4")
new Class4;
coz in this way, all the things MFC offers are not meaningful.
also i donot want to use serialization, since i want to change file contents manually
and I overviewed many MFC books, but no solution . Anybody konws how to do?
Thanx in advance.
CRuntimeClass* pClass=RUNTIME_CLASS(CMyClass) ;
to get pClass,
then
pClass->CreateObject();
to do dynamic creation, but question:
It is not allowed to use a variable in RUNTIME_CLASS macro, so if I want to read in a string from a file, and the contents of this string is a class name, according to the class name in the string, i do dynamic creation, how should i do ?
Note: I donot want to do the following way:
read ClassName to str
if (str == "Class1")
new Class1;
else if (str == "Class2")
new Class2;
else if (str == "Class3")
new Class3;
else if (str == "Class4")
new Class4;
coz in this way, all the things MFC offers are not meaningful.
also i donot want to use serialization, since i want to change file contents manually
and I overviewed many MFC books, but no solution . Anybody konws how to do?
Thanx in advance.