you can't do that here.
you have to assign the value in the constructor function.
fall::fall()
{
g = 9.81;
}
or you can make it a constant.
const double g = 9.81;
a class is a variable type. It does not execute code directly inside the definition. All code has to be in one of the member functions.
Last edited on
Thank you @jonnin and @joe864864. But it seems too confusing :/. I need to study constructors.