So, im ok understanding the classes from this tutorial -Classes in C++ - Cprogramming.com, but what i can't understand and im so curious about it, how to use Strings in classes? For example:
Here is the output: Attachment 12810.Code:#include <iostream>
using namespace std;
class Computer
{
public:
Computer();
//Constructor
~Computer();
//Destructor
void setSpeed (int p);
int readSpeed();
void setMemorySpeed(int r);
int readMemorySpeed();
protected:
int normalSpeed;
int memorySpeed;
};
Computer::Computer()
{
normalSpeed = 0;
memorySpeed = 0;
}
Computer::~Computer()
{
}
void Computer::setSpeed(int p)
{
normalSpeed = p;
}
int Computer::readSpeed()
{
return normalSpeed;
}
void Computer::setMemorySpeed(int r)
{
memorySpeed = r;
}
int Computer::readMemorySpeed()
{
return memorySpeed;
}
int main()
{
Computer compute;
compute.setSpeed(150);
compute.setMemorySpeed(512);
cout<< "Your normal speed is: " << compute.readSpeed() << "\n"
<< "Your memory speed is: " << compute.readMemorySpeed() << "\n";
cin.get();
}
Now, what i want is: a String that shows for example: Your Computer OS type is: Windows XP - SP3.
Thank you infront.