Archived

This topic is now archived and is closed to further replies.

Zerosignull

Multiple Souce Files

Recommended Posts

Im haveing a lil problem with getin my main souce file recognising my Objects created in my other source files eg.. ////////////////////////////////////// class _myClass { //has a bender if I specifying ne thing after //class when i compile this source file _myClass(); ~_myClass() public: void afunction(); }; extern _myClass WorkDamit; _myClass::afunction() { cout << "im working"; } /////////////////////////////////////// #include _myclass Workdamit; //wont compile past this point void main() { WorkDamit::aFunction(); } help!!! ~prevail by daring to fail~

Share this post


Link to post
Share on other sites
    
//////////////////////////////////////////////////

// MyClass.h


class MyClass
{
public:
void aFunction();
};

//////////////////////////////////////////////////

// MyClass.cpp


#include (MyClass.h)

void MyClass::aFunction()
{
// Do something

}

//////////////////////////////////////////////////

// Main.cpp


#include (MyClass.h)

MyClass a_class;

void main(void)
{

a_class.aFunction();

}



That's all, folks...



MatrixCubed
http://MatrixCubed.org








Edited by - MatrixCubed on August 10, 2001 7:33:25 AM

Share this post


Link to post
Share on other sites
The layout of your code isnt very clear from your post...
it should look something like this....

  

// IN MYCLASS.H //

class _myClass
{
public:
_myClass();
~_myClass();
void afunction();
};

extern _myClass WorkDamit;

// IN MYCLASS.CPP //


_myClass::afunction()
{
cout << "im working";
}

_myClass::_myClass()
{
}

_myClass::~_myClass()
{
}

// IN MAIN.CPP //////////////////////////


#include <stuff.h>
#include "myclass.h"

_myclass Workdamit;

void main()
{
WorkDamit::aFunction();
}



This should work, unless I have missed something....

Share this post


Link to post
Share on other sites