ChinaUnix.net
相关文章推荐:

为什么可以声明常量类 不用初始化

[code] class foo { public: int a[2]={1,2}; }; [/code] 编译错误.

by book11 - C/C++ - 2006-08-24 22:16:38 阅读(2295) 回复(7)

相关讨论

const float pi=3.1415926; 与 const float pi=3.1415926F; 有何区别?不是已经明确定义了float型吗,后面为何还有加了F来说明是float型? 感谢!!

by ciwsecurity - C/C++ - 2009-05-23 15:54:56 阅读(3162) 回复(9)

[code] typedef map;Map; class T { private: static Map m; }; [/code] Map初始化后将不会再被修改

by karabiner - C/C++ - 2004-09-13 10:46:07 阅读(5695) 回复(1)

即使不用定义,只要声明,也可以编译通过? 在看EffectiveC++条款34时,有这段话: [quote]尽可能使用声明,而不使用的定义。因为在声明一个函数时,如果用到某个,是绝对不需要这个的定义的,即使函数是通过传值来传递和返回这个: class Date; // 声明 Date returnADate(); // 正确 ---- 不需要Date的定义 void takeADate(Date d); 当然,传值通常不是个好主意(见...

by maxxfire - C/C++ - 2009-07-21 14:22:24 阅读(1336) 回复(5)

数组 Java中的数组跟C/C++这些语言中的数组的语法结构很相似。但是,Java去掉了C/C++中的可以通过[]或者使用指针来访问元素的功能。这种在C/C++中被普遍接受的功能虽然强大,但是也让Bug横行的软件更容易出现。因为Java不支持这种直接通过指针来操纵数据,这的Bug也被消除了。 数组是一包含被称为元素的值的对象。这就为你在程序中移动或保存一组数据以很方便的支持,并且允许你根据需要访问和改变这些值。用一个小例子来说:...

by gslsok - Java文档中心 - 2008-04-20 14:05:55 阅读(906) 回复(0)

#include #include using namespace std; main() #if 0 { //error note: // non-aggregates cannot be initialized with initializer list typedef struct test{ string a; string b; int c; }; struct test *pins; struct test ins1={"abc","def",3}; pins=&ins1; pins->a="aaa"; pins->b="bbb"; } #endif #if 0 { // success! typedef struct te...

by user2003 - C/C++ - 2007-01-11 15:35:41 阅读(2954) 回复(4)

有如下代码段: [code] /** Encapsulates literal text. This is always constructed using an _LIT macro. This class is build independent; i.e. for a non-Unicode build, an 8-bit build variant is generated; for a Unicode build, a 16 bit build variant is generated. The class has no explicit constructors. See the _LIT macro definition. */ template class TLitC { public: // 一些成员函数,但没有...

by disheng727 - C/C++ - 2009-08-09 20:28:23 阅读(1618) 回复(5)

在在while循环的线程中, 定义了一个字符串数组char test[256], 然后把这个数组赋值给一个string teststr, teststr = test, 开始循环没有问题,在运行多个周期后, 打印出来的teststr的长度(用length()取)为0, 开始都是正常的, 是不是函数堆栈的大小有限制?

by tankxu - C/C++ - 2009-06-03 22:41:44 阅读(1370) 回复(3)

我记得的静态变量是必须初始化的,而下面三段代码 #include using namespace std; class test { public:     static int x; }; int test::x = 0; int main() {     test::x = 1;     return 0; } #include using namespace std; class test { public:     static int x; }; //int test::x = 0; int main() { /...

by zhongyj - C/C++ - 2008-05-19 10:29:39 阅读(8951) 回复(2)

求助: 请看以下代码: #include ; #include ; using namespace std; class node { public: node(int x1,int x2):x(x1),y(x2){} int x,y; vector; a(2); }; int main() { node a(2,3); return 0; } 在VC6.0(已安sp6补丁)环境下编译出现以下错误: c:\program files\microsoft visual studio\myprojects\alexander\app4\app4.cpp(9) : error C2059: syntax error : 'constant' Error executing cl....

by Alexander1983 - C/C++ - 2005-05-17 13:15:16 阅读(2146) 回复(3)

template; class Buffer { T v; int sz; public: buffer():sz(i){} } 请问sz(i)的意思是什么?是不是将sz赋值为i? 是不是所有的成员都可以如此初始化?还是有特定的使用限制?

by nicksean - C/C++ - 2003-07-01 10:10:25 阅读(1237) 回复(4)