init1.c
来自「this is a gcc file, you can download it 」· C语言 代码 · 共 26 行
C
26 行
// Build don't link: // GROUPS passed initializationclass foo {public: int data; foo(int dat) { data = dat; }};class bar {public: foo f[3] = { 1, 2, 3 }; // works: f[0] = 1, f[1] = 2, f[2] = 3 // ERROR - ANSI C++ forbids initialization of member f;};class bar2 {public: foo f[3] = { foo(1), foo(2), foo(3) }; // ERROR - ANSI C++ forbids initialization of member f; // does not compile -- error: field initializer is not constant};int main(void){ foo f[3] = { foo(1), foo(2), foo(3) }; // standard C++ ... and it works too! :) return 0;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?