Hello, I am having problem to define a constuctor of a class with private member which is also of a const type. When I try to compile it complains that the const members do not have initalized data. Hmm, anyway it works fine if I remove const. However is it possible to define a constructor with const members which is possible to set values to?
I know that const is values you can't change values on, but exercise says to use const. help is appreciated.:)
e.g. I want to create an object of a person
Bike bicycle (2, "Monark", "blue", 24.11);
and here is the constructor code
Bike::Bike(const int wheel, const string brand, string color, double wheelsize) {
w = wheel;
b = brand;
c = color;
ws = wheelsize;
}
and here is the class file
class Bike {
public:
Bike (const int, const string, string, double);
private:
const int w;
const string b;
string c;
double ws;
};