Axxer Wrote:Declaring a function outside of a class is a little bit weird. It destroys the sense of scope you get with Java in that a function is a part of an object; instead, a function simply acts upon an object (as it does to a struct in C).
Well, you can declare a class function within the class, and it can then be defined outside of the class. Be careful how you use those two terms. Also, you know that you can define a class function inside the class declaration, so you can get the exact same look as in Java. This is uncommon for many C++ programmers, however.
Most projects only declare the class functions in the class for organization. Your header files (.h) will contain the class declaration along with its function declarations and variables. This is a handy way to browse at a glance what the class is and what it does. The actual definitions usually go in C++ source code files (.cpp). In something like Dolphin, it helps to keep the code manageable imo, especially during compilation. The "scope" remains clear enough when you're working with the project files and when all of your functions are prefaced by "YourClassName::".
Also, I think the word you're looking for to describe C is procedural just for reference
Axxer Wrote:In C++, I almost don't see the use for an object when the methods are declared outside anyway. You might as well use an explicit parameter by passing a struct into the function.
But functions can be defined inside the class, if you so choose. I don't see why the location of where it's declared determines its usefulness or not, as long as it has the necessary functionality. I think what you're trying to say is something like "In C++, why have objects at all when you can just use plain old functions and structs?" Passing around a sturcture (hopefully via pointer or reference) gets tiresome pretty quickly as opposed to creating an object and calling its own function. Like I said, it's for readability and organization as well; having objects around helps describe what the code does. You'd be very hard-pressed to write an efficient and large-scale program like Dolphin with C-style structs and functions alone (not impossible, but not easy, and definitely not clean or clear).