Home > Back-end >  Source code is as follows, there is no constructor to match the parameter list examples of how to so
Source code is as follows, there is no constructor to match the parameter list examples of how to so

Time:09-26

# include "iostream"

# include "string. H"

using namespace std;

The class CPoint

{

Private:

Int X;

Int Y;

Public:

CPoint (int x=0, int y=0)

{

X=X, Y=Y;

}

CPoint (CPoint & amp; P)

{

X=p.X;

Y=p.Y;

}

Int GetX ()

{

Return the X;

}

Int GetY ()

{

The return of Y;

}



};

The class CShape

{

Private:

Char Color [10].

Public:

CShape (char * c)

{

Strcpy (Color, c);

}

Void the Draw ()

{

Cout & lt; <"The Draw a shape. The color is" & lt;
}

Void PrintColor ()

{

Cout & lt;
}

};

The class CLine: public CShape

{

Private:

CPoint Start;

CPoint End;

Public:

CLine (CPoint s, CPoint e, char * c) : CShape (c), Start (s) and End (e)

{}

Void the Draw ()

{

Cout & lt; <"The Draw a Line from the (" & lt;
Cout & lt; <") to (" & lt;
PrintColor ();

}

};

The class CCircle: public CShape

{

Private:

CPoint Center;

Int the Radius;

Public:

CCircle CPoint CTR, int r, char * (c) : CShape (

CodePudding user response:

Topic: define a point class CPoint, a bit the coordinates of the data members, to define a class CShape geometry data members only color, base class for class CShape derived qualification period of CLine and round CCircle, line kind of CLine data members including start and end (child objects of CPoint class), circle CCircle data members including center (for CPoint class sub-objects) and radius,

CodePudding user response:

The constructor CShape (char * c)
Try to CShape (const char * c)

CodePudding user response:

Nice, perfect solution

CodePudding user response:

This can be used before, now update in front with const char * OK,
  • Related