|
-
Dec 22nd, 2001, 08:58 PM
#1
Thread Starter
Lively Member
Including .cpps
Is it possible to include .cpps? There are integer data types in my main.cpp I want to use in another .cpp, how would I do this?
-
Dec 22nd, 2001, 09:28 PM
#2
Fanatic Member
Yes, it's possible, but it's not good practice to include .cpp files. You should have it in a .h file instead. Just do:
Code:
#include "file.cpp"
// Or
#include "file.h"
Alcohol & calculus don't mix.
Never drink & derive.
-
Dec 22nd, 2001, 09:53 PM
#3
Thread Starter
Lively Member
How do I put it in a .h file?
-
Dec 23rd, 2001, 06:47 AM
#4
Addicted Member
If you want to do an .h-file it's only to open a new file and write:
Code:
#ifndef _name_h_
#define _name_h_
#include <iostream>
.....
using namespace std;
code.......
.
.
.
#endif
save it later as an .h-file.
If you want your variables to be global, then you have to declare them to be that, else they'll be local variables in your main.cpp-file.
good luck!
Last edited by [praetorian]; Dec 23rd, 2001 at 12:43 PM.
[p r a e t o r i a n]
-
Dec 23rd, 2001, 07:21 AM
#5
AAAHH
NEVER include cpp or c files! NEVER NEVER NEVER!
A header file is simply a file where type, variable and function declarations are. You include the header in every module (.c or .cpp file) where you need the types/functions/variables. NOT vice versa!
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|