Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果有一个刚刚继承的类 Book,QList< char >我想知道是否可以QList从 Book 中引用?
QList< char >
QList
例如,如果我想遍历 中的元素,QList我该怎么做?下面是如果 Book 没有继承我将如何执行此操作的代码QList。
QList<char> list; foreach (char element, list) { cout << element << endl; }
foreach(char element, *this) { cout << element << endl; }
顺便说一句,我不确定您要实现什么目标,但我想这是您应该支持组合而不是继承的情况。