Hello,everybody here.
I am a newbie in programming and I only use this website for my learning resource.
Now I have studied C++ here for over 60 hours on my own.
And I am studying Class(1) in the tutorial and have a question below.
if A class is defined with a constructor within it and the constructor is not a default one, we cannot declare an object of that class by:
myclass abc; (assume that myclass is the class_name).
but if abc is declared within anonther class as a parameter,
myclass abc is accpetable.
class circle
{
double r;
double t;
public:
circle(double a,double b)
{
r = a;
t = b;
}
double area()
{
return t * r*r;
}
};
class cylinder
{
double height;
circle ccc; //it's ok here. but it' not ok with the main function.
public:
cylinder(double, double,double);
double volume()
{
return ccc.area() * height;
}
};
cylinder::cylinder(double a, double c,double b) :ccc(a,c), height(b) {}