class shape{
public:
shape(string a, bool b):name(new string), moral(new bool){
*name=a;
*moral=b;
}
shape():name(new string),moral(new bool){
*name="shape";
*moral=true;
}
~shape(){
delete name;
delete moral;
}
protected:
string* name;
bool* moral;
};
class circle:public shape{
public:
circle(string s, bool bb, double d):shape(new string, new
bool),radius(new double){
}
protected:
double * radius;
};
Recently, I was trying to pick up c++. Here is a sample code I wrote when learning the property of inheritance. There are errors show on "shape(new string, new bool)" in child class circle. I am not sure what is right syntax to do that. Also, I noticed if were using pointers in classes, the form of initialize list were used to allocate memory instead of assigning values. Are there better expressions and syntax I can use to do both? Thank you guys in advance.