Sign in to follow this  

Class Member Function Definition inclusion question

This topic is 3813 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok, I'm reading "C++ in Plain English" By Brian Overland and I think its missing a whole section or something is wrong with his example. Basically heres all the files i typed in from the example: http://www.uni-code.com/C-C++/book%20example/ What I'm confused about is the class member function definition isn't included in the main file so how would the class run properly? Would I have to include the "cstr.cpp" file in the main.cpp file to work properly? Thats the only way I'm seeing this working. Am I correct or is there something I should know about Classes this book isn't telling me.

Share this post


Link to post
Share on other sites
The class is defined in cstr.h, I really don't see what the problem is here. Definitions go in headers and code goes in source files, that's how it works with C and C++.

I would suggest though that you throw your book in the garbage. Any book with "C++" in the title that uses C-style strings is crap. Plus he used the unsafe C functions instead of the ones meant to prevent buffer overflows. I could write a better book.

[Edited by - Scet on July 8, 2007 6:47:45 PM]

Share this post


Link to post
Share on other sites
Doesn't the book explain the pre-processing, compilation, link process?

Might as well read through a recently published tutorial, which explains, among other things, the build process as well.

And I agree, that the examples presented have little to do with C++. They are just the usual C with classes. For a C++ book, the only string manipulation demonstrated should be with std::string.

Long story short:
- Compiler pre-processes and compiles all the .cpp files.
- When a .cpp file #includes another file, the contents of that file are inserted into the cpp file.
- End result of this are object files, compiled code
- Linker than connects these into an executable, and connects the symbols

Share this post


Link to post
Share on other sites
Quote:

Doesn't the book explain the pre-processing, compilation, link process?


Naw it really doesn't, thanks i'll check out that tutorial now.

Share this post


Link to post
Share on other sites

This topic is 3813 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this