Code:
class Computer
{
public:
Computer(int ps = 0, int mem = 0, int ds = 0) :
processorspeed(ps), memory(mem), drivespace(ds)
{ }
private:
int processorspeed;
int memory;
int drivespace;
};
This line:
Code:
Computer(int ps = 0, int mem = 0, int ds = 0)
is what you should focus on to have a constructor that takes different values. Just like any other function, the parameters with " = 0" are optional, meaning they will be 0 if the user doesn't specify them. The downside is that if the user wants to indicate memory but not processorspeed, they must add the 0 for processor speed also (like in this example):
Code:
Computer myComputer(0, 128);
which creates a computer with memory at 128 and processorspeed and drivespace at 0. Note that the default doesn't have to be 0, I just chose that.