Class Member Function Definition inclusion question

Started by
2 comments, last by scheols 16 years, 9 months ago
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.
Advertisement
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]
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
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.

This topic is closed to new replies.

Advertisement