GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 17-Nov-2003, 09:52
Nasimov Nasimov is offline
Invalid Email Address
 
Join Date: Nov 2003
Location: EarthPlanet
Posts: 2
Nasimov is an unknown quantity at this point

More than one file.


When compiling more than one file at once, do you have to put the include statements in all the files that need them, or just the main?
Ex. Can you do this:

File 1:
class A {
public:
int a;
A() {
a = sqrt(2835);
}
};

File 2:
class B {
public:
int b;
B() {
b = pow(2416, 4)
}
};

File 3:
#include <iostream>
#include <cmath>
using namespace std;

int main() {
A a;
B b;
cout << a.a;
cout << b.b;
}


Or would each file have to include <cmath> ?
Thanks..
  #2  
Old 27-Jan-2004, 19:46
dsmith's Avatar
dsmith dsmith is offline
Senior Member
 
Join Date: Jan 2004
Location: Utah, USA
Posts: 1,351
dsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of light
Quote:
Originally Posted by Nasimov
Or would each file have to include <cmath> ?
Thanks..

It depends.

Are File 1 and File 2 header files or code files? If they are the actual code (.cpp) files, then they would each need to have the include statement. If they were header files, then the include would only need to be in main, but before your own includes.
 
 

Recent GIDBlogDeveloping GUIs with wxPython (Part 2) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading from file jmenendezr C++ Forum 2 26-Feb-2006 16:00
Limited file size.... lament Apache Web Server Forum 2 31-May-2004 13:35
How to search a huge text file for data? JdS MySQL / PHP Forum 7 27-May-2003 09:27
Sydog's DVD to Divx Conversion Guide asanthadenz Computer Software Forum - Windows 1 14-Mar-2003 14:08
How Do i get php to find out the file type of a file for me? viperman95833 MySQL / PHP Forum 2 08-Mar-2003 09:48

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 06:46.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.