Ok.. yet another homework.. hope I'm not bugging you guys out too much.
"Make a program that processes computer orders. There are two ways computers can be ordered. Either in 3 packages (A, B, C) or custom configured computers. The custom computers can be modified in 3 ways: (CPU Speed, Hard Drive, RAM)
Package A: 75 (Mhz) 1(GB) 16(MB of RAM)
Package B: 100 (Mhz) 1.5(GB) 16(MB of RAM)
Package C: 133 (Mhz) 2(GB) 32(MB of RAM)
"
And heres my program:
The int main() is a given, so that can't be modified.Code:#include<iostream.h> class Computer { public: void display(char a) { if(a=='A') { cpuSpeed=75; hardDrive=1; memory=16; cout<<"A "<<cpuSpeed<<" "<<hardDrive<<" "<<memory<<" "<<endl; } if(a=='B') { cpuSpeed=100; hardDrive=1.5; memory=16; cout<<"B "<<cpuSpeed<<" "<<hardDrive<<" "<<memory<<" "<<endl; } if(a=='C') { cpuSpeed=133; hardDrive=2; memory=32; cout<<"C "<<cpuSpeed<<" "<<hardDrive<<" "<<memory<<" "<<endl; } } void display(int b,double c,int d) { cpuSpeed=b; hardDrive=c; memory=d; cout<<"Custom "<<cpuSpeed<<" "<<hardDrive<<" "<<memory<<" "<<endl; } private: int cpuSpeed, memory; double hardDrive; }; int main() { Computer compaq(50,0.5,8), toshiba('A'), gateway('C'); compaq.show(); toshiba.show(); gateway.show(); return ; }
When I compile it, errors are given, such as "Cannot convert int to Computer.."
Can anyone point out my mistakes?



LinkBack URL
About LinkBacks



