I encountered the following while reading some C++ code.
Consider these two code examples:

Code:
class Foo {          // Declares class Foo
public:
    int x;           // Member variable
 
    Foo(): x(0) {    // Constructor for Foo,
    }                //  initializes x
 
    int bar(int i) { // Member function bar()
        return 3*i + x;
    }
};
Code:
class Foo {          // Declares class Foo
public:
    int x;           // Member variable
 
    Foo() {    // Constructor for Foo,
        x(0);    // initializes x
    }
 
    int bar(int i) { // Member function bar()
        return 3*i + x;
    }
};
I don't know what the difference is between how x is initialized in each.
Are they the same thing, just multiple ways to do it?