~译正确且输?Q这说明Q在C语言中,可以l无参数的函C送Q意类型的参数Q但是在C++~译器中~译同样的代码则会出错。在C++中,不能向无参数的函C送Q何参敎ͼ出错提示“'fun' : function does not take 1 parameters”?br> 所以,无论在Cq是C++中,若函C接受M参数Q一定要指明参数为void?br> 规则三小心用void指针cd
按照ANSI(American National Standards Institute)标准Q不能对void指针q行法操作Q即下列操作都是不合法的Q?br>
]]>Type Attribute alignedhttp://www.shnenglu.com/zmllegtui/archive/2009/11/22/101617.htmlzml_cnnkzml_cnnkSun, 22 Nov 2009 06:28:00 GMThttp://www.shnenglu.com/zmllegtui/archive/2009/11/22/101617.htmlhttp://www.shnenglu.com/zmllegtui/comments/101617.htmlhttp://www.shnenglu.com/zmllegtui/archive/2009/11/22/101617.html#Feedback0http://www.shnenglu.com/zmllegtui/comments/commentRss/101617.htmlhttp://www.shnenglu.com/zmllegtui/services/trackbacks/101617.html
Type attribute aligned allows you to specify the alignment of a structure, class, union, or enumeration. The syntax and considerations for specifying alignment factor are the same as for variable attribute aligned. Like variable attribute aligned, type attribute aligned can only increase alignment. Type attribute packed is used to decrease alignment.
If the attribute appears immediately after the class, struct, union, or enumeration token or immediately after the closing right curly brace, it applies to the type identifier. It can also be specified on a typedef declaration. In a variable declaration, such as
class A {} a;
the placement of the type attribute can be confusing.
In the following definitions, the attribute applies to A:
struct __attribute__((__aligned__(8))) A {};
struct A {} __attribute__((__aligned__(8))) ;
struct __attribute__((__aligned__(8))) A {} a;
struct A {} __attribute__((__aligned__(8))) a;
typedef struct __attribute__((__aligned__(8))) A {} a;
typedef struct A {} __attribute__((__aligned__(8))) a;
In the following definitions, the attribute applies to a:
__attribute__((__aligned__(8))) struct A {} a;
struct A {} const __attribute__((__aligned__(8))) a;
__attribute__((__aligned__(8))) typedef struct A {} a;
typedef __attribute__((__aligned__(8))) struct A {} a;
typedef struct A {} const __attribute__((__aligned__(8))) a;
typedef struct A {} a __attribute__((__aligned__(8)));
虚函数只能借助于指针或者引用来辑ֈ多态的效果Q如果是下面q样的代码,则虽然是虚函敎ͼ但它不是多态的Q?br>class A { public: virtual void foo(); }; class B: public A { virtual void foo(); }; void bar() { A a; a.foo(); // A::foo()被调?br>}
以下Z个简单的虚函数和U虚寒数的用演C,目的是抛砖引玉! //father class class Virtualbase { public: virtual void Demon()= 0; //prue virtual function virtual void Base() {cout<<"this is farther class"<}; }; //sub class class SubVirtual :public Virtualbase { public: void Demon() { cout<<" this is SubVirtual!"<<endl;}
void Base() {cout<<"this is subclass Base"<<endl;} };