C++ Classes

Hey Everybody

First off just joined this forum and it looks promising! But let's get to the point of this trivial question:

For a while now I have been reading up about classes and have have a bit of success as I can program them at the top in between the main() and #include file headers but I am now looking onto splitting the declaration and implementation between a header file and a cpp file and would like a generic template for them for example:

1
2
3
4
5
6
7
class foo
{
  private:
  int bar, baz;
  public:
  void foo (int);
};


and then whatever I would put into the cpp file.

Sorry If it sounds confusing so I hope someone knows what I mean!

- Simon
Take a look at this:
http://cplusplus.com/forum/articles/10627/

I think it has what you need, plus some other tidbits.
Thank you so much, It was exactly what I was looking for.
Just a quick question about classes again, I have started my c++/SFML game finally and I need to know when to include what? The link you gave me was very helpful but said nothing about what to include in derived classes, such as in my weapons system.

The Class hierarchy goes like this, suggested by someone else on another thread here:

Item >> Weapon >> Heavy Machine Gun

or

Item >> Weapon >> Flash Bang

Now in each class I use SFML with the header:
#include <SFML/Graphics.hpp>
Would It produce errors If I include this in multiple headers or source files? In my header for controls I know I use the sf::Event event; (which I think is a variable?) and will probably need to include the sfml graphics in that header.

Thanks a lot (Sorry for the double question in one thread :) )
Topic archived. No new replies allowed.