I have two class Window
and TitleWindow
, which Window is base class.
I am doing a downcast with the code:
Window objs2[num2];
for(int j=0;j<2;j++)
{
infile2>>str3>>size2>>str4;
if(str3=='T')
{
TitledWindow *tApp2= (TitledWindow *) &objs2[j];
tApp2->setT(str4);
tApp2->resize(size2);
tApp2->display();
tApp2->printV();
}
}
Where setT, resize,display
and printV
are the member functions of TitleWindow
.
The code is compiled, but when running it return with memory fault. How should I fix it please?