|
-
December 1st, 2010, 05:35 PM
#1
[beginner] Include problems tidying up code
I've currently trying to convert a little project written in C++ into a more conventional style. I'm learning the very basics of C++ and I thought it would help me to understand. What the original author has done is write a lot of code in header files. He has used them almost exclusively. I thought it would be a good idea to create proper header and .cpp files.
The header I'm looking at right now has no includes or anything. It goes straight into defining the one function that it consists of. When I try to put the prototype of the function in the header, and the actual function into its own .cpp file I get a lot of problems with non included variables (even namespace std).
What was available to the old header when it had the whole function in it? How could the old header have this information and the cpp file I created doesn't?
Just to clarify:
older header had:
void func_name() {
code, no sign of any includes
}
Now:
heade:
void func_name();
cpp file:
void func_name() {
code, no sign of any includes
exact same as previous.h
}
Thanks you for your help.
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
|