Jump to content
  • Advertisement
Sign in to follow this  
3Dgonewild

Classes & headers (C++)

This topic is 4214 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

My question is simple...i think.. Im looking for a way to split classes in different source files , but i stuck with headers. Can someone help me a little?. Here's a test class that i would like to include in my main application :
//globals.cpp
class globals
{
public:
string directory,tmpname;
int cCOUNT;
globals();
};

globals::globals()
{
tmpname="name";
directory="c:\\app\\";
cCOUNT=96;
}

Share this post


Link to post
Share on other sites
Advertisement
Very simple. Put the class definition in a header file instead, and the functions in the class in a CPP file.

Something like:

// globals.h

#pragma once // If you're using Visual Studio, otherwise #ifndef etc.

class globals
{
//...
};

//--------------------------------
// globals.cpp

#include "globals.h"

globals::globals()
{
//...
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!