Consider the sample program below:
#include <iostream>
using namespace std;
class test
{
public:
static const float data;
};
float const test::data = 10; // Line1
int main()
{
cout << test::data;
cout << "\n";
return 0;
}
Please note the comment Line1
in the sample code.
Questions:
- Is
Line1
doing the initialization of the date memberdata
? - Is
Line1
the only way to initialize a static const non-integral data member?