ChinaUnix.net
相关文章推荐:

struct 有构造函数吗

[code] typedef struct zz{ int a; int b; } zz_t; [/code] 我想指定一个默认值 每次定义一个zz_t变量的时候就自动这个值 能行

by bleem1998 - C/C++ - 2005-05-24 17:40:54 阅读(4823) 回复(4)

相关讨论

不好意思,可能问的比较菜。我在试验用C实现多态的时候,遇到了这个问题: [code]//poly.c #include ; #include ; #include ; typedef void (*FPTR)(void *p); typedef struct student { int age; int score; char name[128]; FPTR func; } Stu; void nop(void *p) { printf("this is a non-operation!!\n"); } void handler(void *p) { Stu *...

by albcamus - C/C++ - 2005-03-25 09:34:11 阅读(5282) 回复(15)

struct STU { char num[10]; float score[3]; }; main() { struct stu s[3]={{“20021”,90,95,85}, {“20022”,95,80,75}, {“20023”,100,95,90}},*p=s; int i; float sum=0; for(i=0;i<3,i++) sum=sum+p->;score; printf(“%6.2f\n”,sum); } 程序运行后的输出结果是 A) 260.00 B) 270.00 C) 280.00 D) 285.00

by xzh2002 - C/C++ - 2004-01-16 22:09:18 阅读(775) 回复(6)

[quote] /** * idr_remove - remove the given id and free it's slot * idp: idr handle * id: uniqueue key */ void idr_remove(struct idr *idp, int id) { struct idr_layer *p; /* Mask off upper bits we don't use for the search. */ id &= MAX_ID_MASK; sub_remove(idp, (idp->layers - 1) * IDR_BITS, id); if (idp->top && idp->top->count == 1 && (idp->layers > 1) && idp->top->ary[0]) { // We c...

by fineamy - 内核/嵌入技术 - 2006-11-28 12:58:57 阅读(946) 回复(1)

[code]class AA { public: ... struct BB{ int a = 0; float b; } privated; BB bb; } [/code] 着重部分那一句,不能这样做,编译器报错(GCC3。2。2) 那我怎样对它做初始化呢?

by 独行侠1 - C/C++ - 2004-09-20 23:38:37 阅读(1199) 回复(3)

能否这样定义: struct ST_MY{ vector<struct ST_AA> items; };

by jchc - C/C++ - 2009-03-22 09:06:38 阅读(3836) 回复(3)

我在gcc后面加上了-fpack-struct选项后我文件中的结构就可以按照字节对齐了。但是我在调试过程中遇到了其他的问题。不知道还别的方法可以让arm-linux下的结构按字节对齐。

by sleetboy - C/C++ - 2007-09-18 08:45:50 阅读(6614) 回复(11)

哪里struct 的电子书下载啊?急!!!!!!!!!11 :em09:

by wildwind - IT图书与评论 - 2004-04-03 22:40:43 阅读(3170) 回复(4)

我们知道数组就很简单,用for 循环。 num=length(num_array); for(i=0;istruct { int a; int b; char c; long d; } num; 怎么列出num里几个元素(4)?各是什么(a,b,c,d). 谢了!

by systemalgorithm - C/C++ - 2006-12-19 12:13:42 阅读(3816) 回复(19)

struct ST_MY { int id; string val; }; struct ST_MY my; my.id = 1; my.val = "123"; vector<struct ST_MY> vst; vst.push_back(my); 能直接这么做

by jchc - C/C++ - 2009-03-21 11:30:14 阅读(1504) 回复(1)

高手们再试试这个问题: http://bbs.chinaunix.net/thread-1134802-1-1.html [ 本帖最后由 makeclear 于 2008-6-3 12:21 编辑 ]

by makeclear - C/C++ - 2009-03-12 20:55:59 阅读(3699) 回复(13)