Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

quesion in constructor

vandamm60vandamm60 Posts: 8Member
hi guys
could some one explain this code for urgent case.
i'll say what the code does in brief, this code take some values to make a window on the screen which contain a rectangle shape thats all.

there's some difficults in the declaration of the attributes & behaviors of this fragment which i'll indicated by arrow from the left side of the code, here is the code.

class RectangleShape {
public:

// here some obstacles in the constructor delaration

rectangleShape(===>SimpleWindow &window ,float Xcoord ,float Ycoord , ===>const color &Color ,float width , float height);

void Draw();

===>color GetColor() const; //what ment by color here

void GetSize(float &width , float &height)const;
float Getwidth() const;
float GetHeight() const;
void GetPosition(float &Xcoord , float Ycoord);
void SetSize(float Width , float height);

private:

===>SimpleWindow &Window; //what does this mean

float Xcente;
float Ycenter;

===>color Color; //what is the kind of variable Color

float Width;
float Height;

};

#include "rect.h"
SimpleWindow W("Main Window" , 8.0 , 8.0);
int ApiMain()
{
W.Open();
RectangleShape R(W , 4.0 , 4.0 , Blue , 2.0 , 3.0);
R.Draw();
return 0 ;
}

Comments

  • LundinLundin Posts: 3,711Member
    : hi guys
    : could some one explain this code for urgent case.
    : i'll say what the code does in brief, this code take some values to make a window on the screen which contain a rectangle shape thats all.
    :
    : there's some difficults in the declaration of the attributes & behaviors of this fragment which i'll indicated by arrow from the left side of the code, here is the code.
    :
    : class RectangleShape {
    : public:
    :
    : // here some obstacles in the constructor delaration
    :
    : rectangleShape(===>SimpleWindow &window ,float Xcoord ,float Ycoord , ===>const color &Color ,float width , float height);
    :
    : void Draw();
    :
    : ===>color GetColor() const; //what ment by color here
    :
    : void GetSize(float &width , float &height)const;
    : float Getwidth() const;
    : float GetHeight() const;
    : void GetPosition(float &Xcoord , float Ycoord);
    : void SetSize(float Width , float height);
    :
    : private:
    :
    : ===>SimpleWindow &Window; //what does this mean
    :
    : float Xcente;
    : float Ycenter;
    :
    : ===>color Color; //what is the kind of variable Color
    :
    : float Width;
    : float Height;
    :
    : };
    :
    : #include "rect.h"
    : SimpleWindow W("Main Window" , 8.0 , 8.0);
    : int ApiMain()
    : {
    : W.Open();
    : RectangleShape R(W , 4.0 , 4.0 , Blue , 2.0 , 3.0);
    : R.Draw();
    : return 0 ;
    : }
    :
    :


    Obviously you need the classes SimpleWindow and color or it won't run.
    What those classes are, I have no idea, but it sounds like a bunch of user defined classes.
  • Eric TetzEric Tetz Posts: 2,141Member
    : ===>color GetColor() const; //what ment by color here

    It's a user-defined type. GetColor() returns a value of that type.

    :===>SimpleWindow &Window; //what does this mean

    It's a reference. If you don't know what a reference is, you would be well served to get a C++ book and learn the language before you start actually trying to write software with it.


    : ===>color Color; //what is the kind of variable Color

    It's of type 'color', which is presumably defined somewhere else in the program.

Sign In or Register to comment.