|
Question #47: Which, if any, of the member function definitions below are ill-formed?
53% on 887 times asked
#include <iostream>
int g_x = 44;
struct Foo
{
int m_x;
static int s_x;
Foo(int x) : m_x(x) {}
int a(int x = g_x)
{
return x + 1;
}
int b(int x = m_x)
{
return x + 1;
}
int c(int x = s_x)
{
return x + 1;
}
};
int Foo::s_x = 22;
int main(int argc, char** argv)
{
Foo f(6);
std::cout << f.a() << std::endl;
std::cout << f.b() << std::endl;
std::cout << f.c() << std::endl;
return 0;
}
|