M
Manuel
Hi.
Consider the case of a class that has some methods that don't require
arguments and not to handle private variables; as example see this
openGL function to draw a square:
void cgutils::drawSquare(float x, float y, float width, float height,
float r, float g, float b, float alpha)
{
glColor4f(r, g, b, alpha);
glBegin (GL_LINE_LOOP);
glVertex3f (x, y, 0.0);
glVertex3f (x+width, y, 0.0);
glVertex3f (x+width, y+height, 0.0);
glVertex3f (x, y+height, 0.0);
glEnd ();
}
I need to call this function in various project files.
Declaring an instance like:
myclass name;
the scope of instance is internally the file where is declared?
Actually, in each file, after the include statements, I declare
a new class instance, using each time a different name.
So if I must use the drawSquare method in 5 project files, I declare 5
instances of class, with 5 different names...
Surely this is not the best way...
At least, what if I use the same name in each file (to have a more clear
code...) ?? Maybe this can create conflict/problems?
thx,
Manuel
Consider the case of a class that has some methods that don't require
arguments and not to handle private variables; as example see this
openGL function to draw a square:
void cgutils::drawSquare(float x, float y, float width, float height,
float r, float g, float b, float alpha)
{
glColor4f(r, g, b, alpha);
glBegin (GL_LINE_LOOP);
glVertex3f (x, y, 0.0);
glVertex3f (x+width, y, 0.0);
glVertex3f (x+width, y+height, 0.0);
glVertex3f (x, y+height, 0.0);
glEnd ();
}
I need to call this function in various project files.
Declaring an instance like:
myclass name;
the scope of instance is internally the file where is declared?
Actually, in each file, after the include statements, I declare
a new class instance, using each time a different name.
So if I must use the drawSquare method in 5 project files, I declare 5
instances of class, with 5 different names...
Surely this is not the best way...
At least, what if I use the same name in each file (to have a more clear
code...) ?? Maybe this can create conflict/problems?
thx,
Manuel