Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Multiple Souce Files


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Zerosignull   Members   -  Reputation: 122

Like
Likes
Like

Posted 09 August 2001 - 11:57 PM

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~

Sponsor:

#2 MatrixCubed   Members   -  Reputation: 199

Like
Likes
Like

Posted 10 August 2001 - 12:32 AM

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

// 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

#3 Sandman   Moderators   -  Reputation: 2136

Like
Likes
Like

Posted 10 August 2001 - 12:41 AM

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....





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS