If have a class, Book, that just inherited QList< char >
, I am wondering if it is possible to reference the QList
from within Book?
For example, if I want to iterate through element in the QList
, how would I do so? Below is the code of how I would do this if Book did not inherit QList
.
QList<char> list;
foreach (char element, list) {
cout << element << endl;
}
foreach(char element, *this) {
cout << element << endl;
}
BTW, I'm not sure what you are trying to achieve but I guess this is a case where you should favor composition over inheritance.