2008年2月26日

OOP Basic--Is the class declaration right?[const]

摘要: Q: in C++ programming language, Is it right to define a class as the following shown: class A{ const int Size=0; } A: no, it's wrong! 在C++中,这样是错误的,常量成员的初始化必须在构造函数中完成。 the initiation of const must be... 阅读全文

posted @ 2008-02-26 10:31 飞天舞者 阅读(266) 评论(0) 推荐(0) 编辑

OOP Basic--what's the diff between struct & class?

摘要: Q: if struct can have the construtor/desctructor and memeber functions ? if so, what's the diff between struct& class? A: Yes! and the diff is that: in Class ,the default variables access typ... 阅读全文

posted @ 2008-02-26 10:27 飞天舞者 阅读(241) 评论(0) 推荐(0) 编辑

STL template&Container--function point & generic class

摘要: please wirte a program to realize the model described in the figure. you shoudl design your program as negeric as possible so that we can enhance the model in the future ealily without making too ... 阅读全文

posted @ 2008-02-26 09:57 飞天舞者 阅读(396) 评论(0) 推荐(0) 编辑

STL template&Container--how to change normal function into generic function.

摘要: Q: Below is usual way we find one element in an array: in this case we have to bear the knowledge of value type"int",the size of array,even the existence of an array. would you re-write it... 阅读全文

posted @ 2008-02-26 09:45 飞天舞者 阅读(265) 评论(0) 推荐(0) 编辑

Programming Basic--what is the output of the following code?

摘要: #include "iostream" #include"string.h" #include "stdio.h" class A{ }; class A2{ char d,e; }; struct B{ }; struct C{ char b,c; }; struct D{ int x,y; }; int main() { count<<sizeof(A)<<endl; cout<<... 阅读全文

posted @ 2008-02-26 09:05 飞天舞者 阅读(378) 评论(0) 推荐(0) 编辑

Programming Basic--what's the diff between const and #define?

摘要: to define a const, we can use const as well as #define in C++ .however the former has more benifits than later. 1) const has data type ,however Macro has no. so the complier can check ... 阅读全文

posted @ 2008-02-26 08:58 飞天舞者 阅读(204) 评论(0) 推荐(0) 编辑

Programming Basic--define a Macro "MIN", which has two parameters and return the less one.

摘要: #define MIN(A,B) ((A)<=(B)?(A):(B)) 阅读全文

posted @ 2008-02-26 08:53 飞天舞者 阅读(250) 评论(0) 推荐(0) 编辑

Programming Basic--what's the use of "ifndef/define/endif";

摘要: to avoid that the head file is referenced more than twice. 阅读全文

posted @ 2008-02-26 08:51 飞天舞者 阅读(200) 评论(0) 推荐(0) 编辑

Programming Basic--why we need to add ' extern "C" ' in C++ program when calling the function which is complied by C complier?

摘要: C++ support overload, but C not. and the name of function in library which is complied by C++ complier is different from that which is complied by C complier. for example: if a function prototyp... 阅读全文

posted @ 2008-02-26 08:49 飞天舞者 阅读(180) 评论(0) 推荐(0) 编辑

Exchange a,b without using other variables

摘要: there are two ways: 1: a=a+b; b=a-b; a=a-b; //in this case, if a or b is a very big number, a+b maybe will overflow. 2: a=a^b; b=a^b; a=a^b; 阅读全文

posted @ 2008-02-26 08:42 飞天舞者 阅读(199) 评论(0) 推荐(0) 编辑

导航

For more information about me, feel free email to me winston.he@hotmail.com