銆銆緙栬瘧姝g‘涓旇緭鍑?錛岃繖璇存槑錛屽湪C璇█涓紝鍙互緇欐棤鍙傛暟鐨勫嚱鏁頒紶閫佷換鎰忕被鍨嬬殑鍙傛暟錛屼絾鏄湪C++緙栬瘧鍣ㄤ腑緙栬瘧鍚屾牱鐨勪唬鐮佸垯浼?xì)鍑洪敊銆傚湪C++涓紝涓嶈兘鍚戞棤鍙傛暟鐨勫嚱鏁頒紶閫佷換浣曞弬鏁幫紝鍑洪敊鎻愮ず“'fun' : function does not take 1 parameters”銆?br> 銆銆鎵浠ワ紝鏃犺鍦–榪樻槸C++涓紝鑻ュ嚱鏁頒笉鎺ュ彈浠諱綍鍙傛暟錛屼竴瀹氳鎸囨槑鍙傛暟涓簐oid銆?br> 銆銆瑙勫垯涓夊皬蹇?jī)鋴社敤void鎸囬拡綾誨瀷
銆銆鎸夌収ANSI(American National Standards Institute)鏍囧噯錛屼笉鑳藉void鎸囬拡榪涜綆楁硶鎿嶄綔錛屽嵆涓嬪垪鎿嶄綔閮芥槸涓嶅悎娉曠殑錛?br>
]]>Type Attribute alignedhttp://m.shnenglu.com/zmllegtui/archive/2009/11/22/101617.htmlzml_cnnkzml_cnnkSun, 22 Nov 2009 06:28:00 GMThttp://m.shnenglu.com/zmllegtui/archive/2009/11/22/101617.htmlhttp://m.shnenglu.com/zmllegtui/comments/101617.htmlhttp://m.shnenglu.com/zmllegtui/archive/2009/11/22/101617.html#Feedback0http://m.shnenglu.com/zmllegtui/comments/commentRss/101617.htmlhttp://m.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)));
铏氬嚱鏁板彧鑳藉熷姪浜庢寚閽堟垨鑰呭紩鐢ㄦ潵杈懼埌澶氭佺殑鏁堟灉錛屽鏋滄槸涓嬮潰榪欐牱鐨勪唬鐮侊紝鍒欒櫧鐒舵槸铏氬嚱鏁幫紝浣嗗畠涓嶆槸澶氭佺殑錛?br>class A { public: virtual void foo(); }; class B: public A { virtual void foo(); }; void bar() { A a; a.foo(); // A::foo()琚皟鐢?br>}
浠ヤ笅涓轟竴涓畝鍗曠殑铏氬嚱鏁板拰綰櫄瀵掓暟鐨勪嬌鐢ㄦ紨紺猴紝鐩殑鏄姏鐮栧紩鐜夛紒 //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;} };