I am learning C++ and came across this code where the constructor is initialised without declaring member variables. Also, the object is created without any parameters. Wouldn't a default constructor be called instead?
Also, if this class is inherited, will the derived class have access to x and y?
// Example program
#include <iostream>
#include <string>
class game
{
public:
game(int x = 0, int y = 100); // Do they get defined as members?
int z;
};
game::game(int x, int y) : z(x)
{
std::cout << x;
}
int main()
{
game g; // passed w/o parameters.
return 0;
}