I have a question regarding the example covered in the section Classes (I) in the Tutorials of C++. Below is the example as given in the Tutorial and i have mentioned my doubt in the comment form in CAPITAL LETTERS:
/ member initialization
#include <iostream>
using namespace std;
class Circle {
double radius;
public:
Circle(double r) : radius(r) { }
double area() {return radius*radius*3.14159265;}
};
class Cylinder {
Circle base;
double height;
public:
Cylinder(double r, double h) : base (r), height(h) {} // HOW CAN r BE ASSIGNED TO base WHEN BOTH ARE OF DIFFERENT TYPES ie. base IS OF CLASS CYLINDER AND r IS OF TYPE DOUBLE
double volume() {return base.area() * height;}
};