Skip to main content
GameDev.net gamedev.net
🔒 Locked

C++ help (Newbie)

Started by Player_0 Jan 13, 2005 at 11:38 PM 3 replies 650+ views
Original Post
Player_0
Player_0
Hello, I'm getting errors in gl.h. I'm making a windows opengl program and whenever I try moving from a single file and to incorporate classes and the like I get errors. Most of them are showing up in gl.h which is ridiculous but I think I've found the problem. The way I have it set up so far is in main.cpp is all the windows stuff and it includes and "Render.h". In Render.h I have class Render : public Utility. Also "private: Utility* ren;". In Render.cpp I include . In Utility.cpp I include again. If gl.h is included twice does that produce the error? If so how can I only include it once for all the files that need it. Another question I have is about syntax. Is: class foo : public bar {} the same as: class bar; class foo{} //uses stuff from bar Thanks for any help and corrections anywhere.
mike25025
mike25025
what are the errors?

Quote:
Another question I have is about syntax.
Is:
class foo : public bar
{}
the same as:
class bar;
class foo{} //uses stuff from bar


no
Oluseyi
Oluseyi
Quote:
Original post by Player_0
If gl.h is included twice does that produce the error?
No.

Read this.
Zahlman
Zahlman
Quote:
Original post by Player_0
Is:
class foo : public bar
{}
the same as:
class bar;
class foo{} //uses stuff from bar

Thanks for any help and corrections anywhere.


No. The latter will not compile unless foo has its own set of stuff with the same names as the stuff it "uses from bar", and in that case it will not actually use the stuff from bar, but its own.

Unless you meant that foo objects are using stuff from bar objects; i.e. the foos either contain an actual bar object (or pointer thereto) in their data or receive them as parameters. In which case the behaviour is still different: in the former case you assert that a foo is-a bar; in the latter, that it has-a bar (or even more weakly, simply talks to bars.)
Enigma
Enigma
Under windows you must always #include before you #include . This is probably the source of your errors in gl.h.

Enigma

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.