-
Yeah, it's not real specific about defining functions though. In fact, none of the examples in the book show defining the functions or making a seperate .cpp in addition to the .h file for the class. The book is entitled "C++ Program Design" by James Cohoon and Jack Davidson. It looks like it was originally published back in '97..
-
I'm still wondering how you decided what type of project to create? You can't just randomly pick a type. Different types of programs are organized differently, and the compiler needs to know what type of program it's looking at. Windows programs(=programs that use windows to interact with the user)are totally different than console programs, which don't have a windows interface.
A windows program has two functions: WinMain() and WindowProc() which are seemingly unconnected. The Windows operating system serves to form the connection between the two. In a console program, there is one function called main() which is the kick off point for your program, and other functions are called from within main().
"I haven't actually done a whole heckuva lot in terms of functions in C++ yet though, but I have dealt with functions of course quite often in the other languages, so I have to figure it to be similar..."
I'm not sure it works that way. You have to implement functions in a specific way in C++ or else the program won't compile.
As for classes in general, you have to start learning about them with simple examples, and then you have to learn about constructors, destructors, copy constructors, and assignment operators and how they are affected by the types of your data members and function definitions.
"In fact, none of the examples in the book show defining the functions or making a seperate .cpp in addition to the .h file for the class."
Most beginning C++ books start off with function definitions in the same file as main(). Then after you learn where they can positioned in the main() file, you learn to separate them into separate files.
-
That totally makes sense.. I appreciate you all taking the time to respond to my questions... Can anyone suggest a good C++ book that I might be able to buy or borrow from the library that would discuss classes and functions a bit better? Or even a website? I think part of my problem is that this book doesn't seem all that great when compared to other programming books that I've read. I've read and re-read this chapter on classes at least 5 times and it still isn't quite sinking in... maybe it's just user error? :)
-
Ivor Horton's Beginning C++
If you want to eventually learn about windows programming(=programs that use windows to interface with the user) using MFC(=a library of classes that spare you from having to reinvent the wheel), then get Ivor Horton's Beginning Visual C++ 6, in which the first 12 chapters are a C++ tutorial, and the second half of the book moves into windows programming with MFC.