I was studying in the famous schaums outline c++ programming book, and i saw something called list initialization - i didn't know that before.
I made a code according to the book, but it raised a lot of compiler errors. I was asking my self where the problem is, so i copied the code from the book, and guess what - it didn't work!
Here's the code:
class Rational {
public:
Rational(int n=0, int d=1) : num(n), den(d) { }
int numerator0 const { return num; }
int denominator0 const { return den; }
private:
int num, den;
};
main()
{
Rational x(22, 7);
cout << x.numerator() << "/" << x.denominator() << endl;
}
Can you tell me what is wrong here ? Thank you in advance. P.S. Written by "pros" yeah right...