Jump to content

  • Log In with Google      Sign In   
  • Create Account

Please help with classes in openGL


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 Mike00   Members   -  Reputation: 122

Like
Likes
Like

Posted 20 April 2000 - 10:20 AM

I''m trying to add a class to my modified lesson14 code. It doesn''t work though. Here''s the section: class myclass{ private: char mydata[6]; public: void printclass(){mydata[0]=''h''; glPrint(mydata);}; }; int DrawGLScene(GLvoid) { glClear(GL_COLOR_BUFFER_BIT / GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glTranslatef(-7.5f,-8.0f,-22.0f); glColor3f(0.5f,0.0f,0.5f); myclass.printclass(); return TRUE; } I get this error message: --------------------Configuration: lesson14 - Win32 Debug-------------------- Compiling... 3dguys.cpp C:\My Documents\lesson14\lesson14.cpp(546) : error C2146: syntax error : missing '';'' before identifier ''myclass'' C:\My Documents\lesson14\lesson14.cpp(546) : error C2501: ''GLclass'' : missing storage-class or type specifiers C:\My Documents\lesson14\lesson14.cpp(546) : fatal error C1004: unexpected end of file found Error executing cl.exe. Lesson14.exe - 3 error(s) Thanks!

Sponsor:

#2 Mike00   Members   -  Reputation: 122

Like
Likes
Like

Posted 20 April 2000 - 10:23 AM

oops! Here''s the real error message:

C:\My Documents\lesson14\lesson14.cpp(566) : error C2143: syntax error : missing '';'' before ''.''
C:\My Documents\lesson14\lesson14.cpp(566) : error C2143: syntax error : missing '';'' before ''.''

The last one was when I tried using GLclass =) Guess there''s no such thing.

#3 acraig   Members   -  Reputation: 471

Like
Likes
Like

Posted 20 April 2000 - 11:39 AM



void printclass(){mydata[0]=''h''; glPrint(mydata);};

There should be no semicolon at the end of this line. See if that helps.


Andrew

#4 Magallo   Members   -  Reputation: 122

Like
Likes
Like

Posted 20 April 2000 - 09:06 PM

First of all cut of the semicolon '';'' at the line

void printclass(){mydata[0]=''h''; glPrint(mydata);};

and change in

void printclass(){mydata[0]=''h''; glPrint(mydata);}

Then you can''t refer to the name of the class to invoke its method but you have to create an instance of the class.

I mean, No

myclass.printclass();

But

myclass mc;
..........
..........
..........
mc.printclass();

Hope I was able to help you....



#5 Mike00   Members   -  Reputation: 122

Like
Likes
Like

Posted 21 April 2000 - 07:58 AM

Thanks!!




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS