Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Anonymous Poster

PLEASE HELP

This topic is 6612 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i defined a class in a header file, now i want to create a variable of this class: DrawQuad var; It works fine for now but when i try to access the variables objects, it stucks: var.a = 1; "a" is of course defined public. VC6 prints following error messages: error C2143: syntax error : missing '';'' before ''.'' error C2501: ''var'' : missing storage-class or type specifiers error C2371: ''var'' : redefinition; different basic types

Share this post


Link to post
Share on other sites
Advertisement
I''m not completely sure, but make sure you have a semicolon at te end of your class definition. example:

class TRIANGLE
{
//whatever
}; <----semicolon

Share this post


Link to post
Share on other sites
Hmmm, it''s hard to tell from just that. Post a small snippet of code (including whatever you''re doing right before the line that breaks). It looks like it might be a syntax error on a previous line not getting detected until that point.

-Brian

Share this post


Link to post
Share on other sites

You can get that error if you declare a variable of a type that''s not defined. Make sure you are including your class''s header file in the .cpp file you are using it in.

// CHRIS

Share this post


Link to post
Share on other sites
i tried to put the struct in the ogl.cpp too, and what happened ? the error came up again !

struct aabb
{
int a;
};

aabb abc;
abc.a = 1;


what am i doing wrong ???????????????? AAAAAAAAAAAAAAAAAAHHHHHHH PLEEEEEEEEASSE HELP!!!!!!!!!!!!!!! AAAAAAAAAAAAAAAAAAAAAAAAAAAAAHHHH

Share this post


Link to post
Share on other sites
Take it easy... you are almost there...

Your problem is that you are trying to assign a value for that member of that class in no-where.

You should do the assignment in a global function like WinMain or in a member function of that class.

-Osmo

Edited by - Osmo Suvisaari on 4/19/00 4:44:33 PM

Share this post


Link to post
Share on other sites
Maybe a silly question, but are you trying to set the class/struct members inside of a function? You can declare a variable globally, and in doing so call any of its constructors, but you can''t do anything else with it until you''re inside a function.

(oh, you can also assign a value to it in global scope, but I always get confused on the syntax for doing that with structs and arrays).

If you are in fact trying to do this within a function, something else is going on because what you''ve written should work.

Share this post


Link to post
Share on other sites
I recommend the use of a member function, but here is anyway an modification of "ogl.cpp" that would compile:

#include "ogl.h"

aabb var;

void InitializeSomething()
{
var.a = 1;
}

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!