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

歡迎來到入門教程網(wǎng)!

C語言

當(dāng)前位置:主頁 > 軟件編程 > C語言 >

C++結(jié)構(gòu)體與類指針知識(shí)點(diǎn)總結(jié)

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

在結(jié)構(gòu)體或類中, 指針訪問其成員函數(shù)或變量通過 "->" 運(yùn)算符或者看代碼注釋部分, 注釋部分的操作不推薦:

#include <iostream>
#include <cstring>
using namespace std;
struct STRUCT
{
  string hello;
};
int main()
{
  STRUCT *str=new STRUCT;
  str->hello="Hello";//或者可以寫成: (*str).hello="Hello"
  cout<<str->hello<<endl;//或者可以寫成: cout<<(*str).hello<<endl;
  delete str;
  return 0;
}
#include <iostream>
#include <cstring>
using namespace std;
class CLASS
{
public:
  string hello;
};
int main()
{
  CLASS *str=new CLASS;
  str->hello="Hello";//同理
  cout<<str->hello<<endl;//同理
  delete str;
  return 0;
}

備注: class中的public不可以省, struct中public可以省 ( 屬于語法部分, 不做解釋 )

關(guān)于類與結(jié)構(gòu)體的指針都是這樣操作 (無論是哪種數(shù)據(jù)類型),

注意: 一定要給結(jié)構(gòu)體或類指針聲明空間, 否則輸出可能會(huì)是亂碼或沒有輸出, 本人更建議使用智能指針, 免得申請(qǐng)釋放空間

以上就是本次介紹的關(guān)于C++結(jié)構(gòu)體與類指針全部知識(shí)點(diǎn)內(nèi)容,感謝大家的閱讀和對(duì)我們的支持。

上一篇:FFRPC應(yīng)用 Client/Server使用及原理解析

欄    目:C語言

下一篇:C++排序算法之插入排序

本文標(biāo)題:C++結(jié)構(gòu)體與類指針知識(shí)點(diǎn)總結(jié)

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

網(wǎng)頁制作CMS教程網(wǎng)絡(luò)編程軟件編程腳本語言數(shù)據(jù)庫(kù)服務(wù)器

如果侵犯了您的權(quán)利,請(qǐng)與我們聯(lián)系,我們將在24小時(shí)內(nèi)進(jìn)行處理、任何非本站因素導(dǎo)致的法律后果,本站均不負(fù)任何責(zé)任。

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

Copyright © 2002-2020 腳本教程網(wǎng) 版權(quán)所有