欧美大屁股bbbbxxxx,狼人大香伊蕉国产www亚洲,男ji大巴进入女人的视频小说,男人把ji大巴放进女人免费视频,免费情侣作爱视频

歡迎來到入門教程網!

C語言

當前位置:主頁 > 軟件編程 > C語言 >

C++空類詳解

來源:本站原創(chuàng)|時間:2020-01-10|欄目:C語言|點擊: 次

空類默認產生的成員:
class Empty {};
Empty(); // 默認構造函數
Empty( const Empty& ); // 默認拷貝構造函數
~Empty(); // 默認析構函數
Empty& operator=( const Empty& );  // 默認賦值運算符
Empty* operator&();               // 取址運算符
const Empty* operator&() const;    // 取址運算符 const

給出一個例子:

復制代碼 代碼如下:

#include<iostream>
using namespace std;

class Empty
{
public:
 Empty *operator&()
 {
   cout<<"AAAA"<<endl;
   return this;
 }
 const Empty* operator&() const
 {
   cout<<"BBBB"<<endl;
   return this;
 }
};

int main(void)
{
  Empty e;
  Empty *p=&e;
  const Empty e2;
  const Empty *p2=&e2;
  cout<<sizeof(Empty)<<endl;
}


運行結果:




可見:
Empty *p=&e調用了Empty* operator&()運算符函數
const Empty *p2=&e2調用了const Empty* operator&() const運算符函數。
空類的大小為1字節(jié)。

上一篇:CFile與CStdioFile的文件讀寫使用方法詳解

欄    目:C語言

下一篇:淺析Boost智能指針:scoped_ptr shared_ptr weak_ptr

本文標題:C++空類詳解

本文地址:http://mengdiqiu.com.cn/a1/Cyuyan/4155.html

網頁制作CMS教程網絡編程軟件編程腳本語言數據庫服務器

如果侵犯了您的權利,請與我們聯(lián)系,我們將在24小時內進行處理、任何非本站因素導致的法律后果,本站均不負任何責任。

聯(lián)系QQ:835971066 | 郵箱:835971066#qq.com(#換成@)

Copyright © 2002-2020 腳本教程網 版權所有