大哥救救菜鸟小弟。。。晕啊。。。
Account是一个父类,personalAccount和companyAccount是两个子类实现银行帐户的链表管理,分别管理一个个人帐户链表和公司帐户链表
每次当我想遍历personalAccount和companyAccount链表时用如下for语句:
for (personalAccount* pS=personalAccount::First();pS->Next();pS=pS->Next())
{
if (pS->AccountId()>21000000&&pS->AccountId()<22000000)
{
//..................
personalAccount::First();中First()、Next()、AccountId()分别是父类Account中定义的返回头指针、下一结点指针、帐号的函数
编译时所有这种for语句都是这种错误:
F:\wwx\main\Main.cpp(208) : error C2440: 'initializing' : cannot convert from 'class Account *' to 'class personalAccount *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
晕啊。。。。。personalAccount 不就是Account的一个子类吗????
那么如何遍历子类的链表呢??????????????????