This is way to broad too answer, what are you trying to do?
If I were to take your question literally, I would post something like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
class Base
{
};
class Child : public Base
{
void something( const Base& )
{
// access achieved
}
};
int main( void )
{
Base base;
Child child;
child.something( base );
}
If I were to take a guess at what you want, I would say that you want to call a function of a base class that has been overridden by the child. In this case:
Thank you for your reply.
In more detail, I have a mainwindow class for all the UI.
When I click on a button it creates a new dialog which says what type of document you want.
When I select an option in NewDocumentSelector dialog, I want to tell MainWindow about this.
I am using Qt library so I could connect the events together but I think MainWindow class will become messy.
I am looking for a way for NewDocumentSelector to be used in MainWindow and other classes for example:
I would say virtual base classes is out, a NewDocumentSelector is not a MainWindow.
I don't think it is an appropriate use of a Singleton pattern, it seems like it is just an excuse to have a global variable.
The first way seems like the best bet, I don't know how to use Qt, but this does look like the way it was intended to be used. If you want to trim down the code in your MainWindow, my first idea would be to create a class derived from whatever you are using to create the action for the dialogue being opened in the first place.