What is a difference between the next two class definitions
class A
{
RQ_OBJECT(“A”)
public:
A(const TGWindow *p, UInt_t w, UInt_t h);
private:
TGMainFrame *fMainFrame;
ClassDef(A,1)
}
and
class B : public TGMainFrame
{
public:
B(const TGWindow *p, UInt_t w, UInt_t h);
ClassDef(B,1)
}
The realizations of these two classes are similar. Only “fMainFrame” is changed on “this” using editor and one line is added
fMainFrame = new TGMainFrame(p,w,h).
Class A works. Class B generate error on the last line of constructor
this->MapWindow(). Of course I can use variant of class A. But is variant of class B correct or not? These were done on Windows XP+SP2 with ROOT 5.11.06
I have never faced a problem when changing the code of a class in a way described by you. Please send a small macro that shows this problem. Please note, in both classes ClassDef should have 0 as second parameter (the object I/O features of ROOT are not needed).
I have not the macro but attached a small Visual Studio project reproducing this error:
Unhandled exception at 0x7c81eb33 in TestA.exe: Microsoft C++ exception: __non_rtti_object @ 0x0012fa00.
On my computer ROOT libraries and include files are in the D:\root\work\lib and D:\root\work\include correspondingly. It can be change in the project properties.
According to MSDN :
Run-time type information (RTTI) is a mechanism that allows the type of an object to be determined during program execution.
There are three main C++ language elements to run-time type information:
The dynamic_cast operator.
Used for conversion of polymorphic types.
The typeid operator.
Used for identifying the exact type of an object.
The type_info class.
Used to hold the type information returned by the typeid operator.
For example :
Given an instance of class C, there is a B subobject and an A subobject. The instance of C, including the A and B subobjects, is the “complete object.”
Using run-time type information, it is possible to check whether a pointer actually points to a complete object and can be safely cast to point to another object in its hierarchy. The dynamic_cast operator can be used to make these types of casts. It also performs the run-time check necessary to make the operation safe.
As “dynamic_cast” is widely used in ROOT, you have to specify /GR compiler option.
Hi,
here is a zip file containing VisualStudio project/solution files for
programs from $ROOTSYS/test.
It contains examples:
how to create pure console application
how to create GUI application
how to create ROOT DLL for class with dictionary
It includes correct compilation/link flags for VisualStudio project
and dictinary generation precompiled step.