#include <iostream.h>
#include "account.h"
#include "savings.h"
#include "checking.h"void main()
{
Savings* pS;
unsigned aN;
float val;
cout <<"please input some account and savings:\n";
cin >>aN >>val;
while(aN){
pS=new Savings(aN,val);
cout <<"please input some account and savings:\n";
cin >>aN >>val;
}
for(Savings* p=(Savings*)pS->First(); p; p=(Savings*)p->Next())
cout <<p->AccountNo() <<" " <<p->AcntBalan() <<endl; for( p=(Savings*)pS->First(); p; ){
Savings* t=p;
p=(Savings*)p->Next();
delete t;
}
pS->First()=NULL; Checking* pC;
cout <<"please input some account and checking:\n";
cin >>aN >>val;
while(aN){
pC=new Checking(aN,val);
cout <<"please input some account and checking:\n";
cin >>aN >>val;
}
for(Checking* p=(Checking*)pC->First(); p; p=(Checking*)pC->Next())
cout <<p->AccountNo() <<" " <<p->AcntBalan() <<endl; for(Checking* p=(Checking*)pC->First(); p; ){
Checking* t=p;
p=(Checking*)p->Next();
delete t;
}
pC->First()=NULL;
}####################
--------------------Configuration: savings - Win32 Debug--------------------
Compiling...
main.cpp
F:\C++程序设计\savings\main.cpp(26) : error C2106: '=' : left operand must be l-value
F:\C++程序设计\savings\main.cpp(36) : error C2371: 'p' : redefinition; different basic types
F:\C++程序设计\savings\main.cpp(18) : see declaration of 'p'
F:\C++程序设计\savings\main.cpp(36) : error C2440: '=' : cannot convert from 'class Checking *' to 'class Savings *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
F:\C++程序设计\savings\main.cpp(39) : error C2371: 'p' : redefinition; different basic types
F:\C++程序设计\savings\main.cpp(18) : see declaration of 'p'
F:\C++程序设计\savings\main.cpp(40) : error C2440: 'initializing' : cannot convert from 'class Savings *' to 'class Checking *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
F:\C++程序设计\savings\main.cpp(41) : error C2440: '=' : cannot convert from 'class Checking *' to 'class Savings *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
F:\C++程序设计\savings\main.cpp(44) : error C2106: '=' : left operand must be l-value
Error executing cl.exe.savings.exe - 7 error(s), 0 warning(s)
#include "account.h"
#include "savings.h"
#include "checking.h"void main()
{
Savings* pS;
unsigned aN;
float val;
cout <<"please input some account and savings:\n";
cin >>aN >>val;
while(aN){
pS=new Savings(aN,val);
cout <<"please input some account and savings:\n";
cin >>aN >>val;
}
for(Savings* p=(Savings*)pS->First(); p; p=(Savings*)p->Next())
cout <<p->AccountNo() <<" " <<p->AcntBalan() <<endl; for( p=(Savings*)pS->First(); p; ){
Savings* t=p;
p=(Savings*)p->Next();
delete t;
}
pS->First()=NULL; Checking* pC;
cout <<"please input some account and checking:\n";
cin >>aN >>val;
while(aN){
pC=new Checking(aN,val);
cout <<"please input some account and checking:\n";
cin >>aN >>val;
}
for(Checking* p=(Checking*)pC->First(); p; p=(Checking*)pC->Next())
cout <<p->AccountNo() <<" " <<p->AcntBalan() <<endl; for(Checking* p=(Checking*)pC->First(); p; ){
Checking* t=p;
p=(Checking*)p->Next();
delete t;
}
pC->First()=NULL;
}####################
--------------------Configuration: savings - Win32 Debug--------------------
Compiling...
main.cpp
F:\C++程序设计\savings\main.cpp(26) : error C2106: '=' : left operand must be l-value
F:\C++程序设计\savings\main.cpp(36) : error C2371: 'p' : redefinition; different basic types
F:\C++程序设计\savings\main.cpp(18) : see declaration of 'p'
F:\C++程序设计\savings\main.cpp(36) : error C2440: '=' : cannot convert from 'class Checking *' to 'class Savings *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
F:\C++程序设计\savings\main.cpp(39) : error C2371: 'p' : redefinition; different basic types
F:\C++程序设计\savings\main.cpp(18) : see declaration of 'p'
F:\C++程序设计\savings\main.cpp(40) : error C2440: 'initializing' : cannot convert from 'class Savings *' to 'class Checking *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
F:\C++程序设计\savings\main.cpp(41) : error C2440: '=' : cannot convert from 'class Checking *' to 'class Savings *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
F:\C++程序设计\savings\main.cpp(44) : error C2106: '=' : left operand must be l-value
Error executing cl.exe.savings.exe - 7 error(s), 0 warning(s)
for(Checking* p=(Checking*)pC->First(); p; p=(Checking*)pC->Next())一行又定义了p