Sign in to follow this  

Creating classes

Recommended Posts

chosenkill6    163
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
fastcall22    10838
[url=]Organizing code files in C and C++[/url]. Also:

// File:"foobar.h"
#pragma once

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

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

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_ );

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