I am learning C++ at the moment, and I came across a lot of examples where classes are declared differently than I'm used to in for example C# or Java. The following thing isn't clear to me:
When defining a class in C#, you code the methods that you are going to use entirely within the class, like so:
public class example{
 public example(){}
public void doSomething(){
 Console.WriteLine("This is something");
}
}
The method "doSomething()" can be accessed by instantiating a new object, and calling object.doSomething();. All clear to me.
Why do people do the following in C++?:
class example{
private: 
 int _thingy;
public:
 void doSomething();
 }
#include <iostream>
example::doSomething(){
 std::cout << _thingy;
}
int main(){
 example x;
 x.doSomething();
 system("pause");
}
Isn't this bad when you are going to reuse the class in other methods?
 
    