Well, first, you need some constructors for your Computer class if you want to pass arguments to them. Without the proper constructors, the following line will cause errors:
Computer compaq(50,0.5,8), toshiba('A'), gateway('C');
Second, there is no show method defined in Computer, you define display, but it doesn't take zero arguments.
Finally, return ; should be return 0;.
Code:
#include<iostream>
using namespace std;
class Computer
{
public:
Computer ( char a );
Computer ( int b,double c,int d ) :
cpuSpeed ( b ), hardDrive ( c ), memory ( d )
{}
void show();
private:
int cpuSpeed, memory;
double hardDrive;
};
Computer::Computer ( char a )
{
switch ( a ) {
case 'A':
cpuSpeed = 75;
hardDrive = 1;
memory = 16;
break;
case 'B':
cpuSpeed = 100;
hardDrive = 1.5;
memory = 16;
break;
case 'C':
cpuSpeed = 133;
hardDrive = 2;
memory = 32;
}
}
void Computer::show()
{
cout<<"CPU: "<< cpuSpeed
<<"\nHD: "<< hardDrive
<<"\nMem: "<< memory
<<'\n'<<endl;
}
int main()
{
Computer compaq ( 50, 0.5, 8 ), toshiba ( 'A' ), gateway ( 'C' );
compaq.show();
toshiba.show();
gateway.show();
return 0;
}
>These are easy assignments your instructor is giving you.
Maybe for you, but these kind of problems tend to give obscure error messages.
-Prelude