Sign in to follow this  

Classes & headers (C++)

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

This topic is 3847 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this