Skip to main content
GameDev.net gamedev.net
🔒 Locked

using multile files...

Started by Moe Sep 6, 2000 at 11:14 PM 4 replies 650+ views
Original Post
Moe
Moe
The current project I am working on is getting rather large. I am trying to have a class with a large number of member functions in it, so that all I do is include the one file and then I can call the functions. I have a couple questions that I hope some of you more exerienced programmers can help me with: 1) Do I just have to do the #include "filename.cpp" thing to just the main source file or should I also include all the other files in the other file (the one with the class in)? 2) I am getting the error: fatal error C1076: compiler limit : internal heap limit reached; use /Zm to specify a higher limit. How do I go about fixing this? 3) Are there tutorials anywhere that explain this? 4) Can I call variables in the member functions that were globally declared in the other file? 5) Can I have one member function call another? I hope someone understands what I am trying to do/say...
Quantum
Quantum
1)put the prototypes in a .h file, and the implementation in a .cpp file
then you just need to #include the .h file anywhere that needs the functions
and dont forget to extern variables..

2).. strange... dunno

3)why would you need a tutorial?

4)see #1

5)yes
Moe
Moe
When you mean 'don't forget to extern variables', what is that and how would I go about doing it (just put the keyword 'extern' in front of my variable when I create it?). As you can tell, I'm not great with C++. I've been using it for less than a year.



Edited by - Moe on September 7, 2000 6:03:06 PM
Quantum
Quantum
ok sorry i was a little vague in my first post..

lets say you have a main.h and main.cpp, and a second.h and a second.cpp

second.cpp needs to access some of main.cpp's functions, variables, and vice versa

        
//BEGIN MAIN.H//

#pragma once //so it only gets compiled once


extern int X;
extern int Y;

void Something();
//END MAIN.H//


//BEGIN SECOND.H//

#pragma once

extern int Bla;

int Function();
//END SECOND.H//


//BEGIN MAIN.CPP//

#include "main.h"
#include "second.h"

//you must put variables in here as well, without extern
int X=0;
int Y=0;
void main()
{
Something();//belongs to main.h

Function();//belongs to second.h

}

void Something();
{
return X*Y;
}

//END MAIN.CPP


//BEGIN SECOND.CPP//

#include "main.h"
#include "second.h"
int Bla;
void Function()
{
return Bla*2;
}
//END SECOND.CPP





..geez.. i hope you can understand that

Edited by - Quantum on September 7, 2000 7:37:01 PM
jonnyfish
jonnyfish
I''m pretty sure that error C1076 is caused by an include file that includes itself, which causes infinite recursion. ...or something like that.




"I'd say pants, but this is a family publication."
Moe
Moe
Thanks! I got that wierd error firgured out. Thanks again!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.