Sign in to follow this  
chosenkill6

Creating classes

Recommended Posts

Is there any way that i can create a class in a seperate file because creating it all in one file gets really confusing. Also can i do this with functions as well? If so how?

Share this post


Link to post
Share on other sites
[url=http://www.gamedev.net/page/resources/_/reference/programming/languages/c-and-c/organizing-code-files-in-c-and-c-r1798]Organizing code files in C and C++[/url]. Also:

[code]
// File:"foobar.h"
#pragma once

// foobar dependencies
#include <string>
class foobaz; // forward declaration

class foobar {
public:
void frobnicate( foobaz& f ); // prototype

private:
int a_;
std::string name_;
static int id_;
};


// File:"foobar.cpp"
#include "foobar.h"
#include "foobaz.h"

int foobar::id_ = 0; // symbol definition

void foobar::frobnicate( foobaz& f ) { // definition
f.impl( a_, name_ );
}
[/code]

Share this post


Link to post
Share on other sites

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