c++11 - Default value for struct member in c++ -
it seems can not give default value struct members in c++,but find code below can compile , run, why? missing something?
struct type { int = 0xffff; }; program:
#include <iostream> using namespace std; struct type { int = 0xffff; }; int main() { // code goes here type val; std::cout << val.i << std::endl; return 0; }
it going depend on compiler use.
for gcc , clang need pass flag -std=c++11 compiler.
support member initializer , other c++11 features:
Comments
Post a Comment