C and C++

Moderators: None (Apply to moderate this forum)
Number of threads: 28629
Number of posts: 94611

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
quesion in constructor Posted by vandamm60 on 7 Jul 2006 at 5:58 AM
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 ;
}

Report
Re: quesion in constructor Posted by Lundin on 7 Jul 2006 at 6:24 AM
: 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.
Report
Re: quesion in constructor Posted by Eric Tetz on 7 Jul 2006 at 12:01 PM
: ===>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.




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.