CuteBeginner
11th February 2013, 19:44
Well firstly it could just be me missing a point about c++ inheritance. I am reading this code from a textbook and I am surprised why it works when I'm thinking it shouldn't.
Here goes the code snippet:
// class header declaration
class ArgumentList : public QStringList {
public:
ArgumentList();
// other function definitions etc
};
// constructor definition
ArgumentList :: ArgumentList(){
if (qApp != NULL)
// this is the statement I'm questioning
*this = qApp->arguments();
}
Now I know qApp->arguments() returns a QStringList, but why is it still possible to call other ArgumentList functions later on when we have now replaced it with a QStringList with the assignment statement.
I have tested my thinking in a similar class and and after assigning a QStringList, I cant access functions defined in my QStringList inherited class. Please help explain this to me as I don't seem to get it.
Many thanks for your help.
Here goes the code snippet:
// class header declaration
class ArgumentList : public QStringList {
public:
ArgumentList();
// other function definitions etc
};
// constructor definition
ArgumentList :: ArgumentList(){
if (qApp != NULL)
// this is the statement I'm questioning
*this = qApp->arguments();
}
Now I know qApp->arguments() returns a QStringList, but why is it still possible to call other ArgumentList functions later on when we have now replaced it with a QStringList with the assignment statement.
I have tested my thinking in a similar class and and after assigning a QStringList, I cant access functions defined in my QStringList inherited class. Please help explain this to me as I don't seem to get it.
Many thanks for your help.