C++中的双冒号(::)
生活随笔
收集整理的這篇文章主要介紹了
C++中的双冒号(::)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
雙冒號(::)的用法(來自https://blog.csdn.net/qq_22424571/article/details/82962367)
A::member就表示類A中的成員member.
B::member就表示類B中的成員member.
例如:System::Math::Sqrt()相當于System.Math.Sqrt()
簡單代碼示例
#include<iostream>
using namespace std;class point{
private:int x,y;
public:point(int,int);void show();
};
//對成員point()進行定義或者重載
point::point(int x, int y){this->x=x;this->y=y;cout<<"獲取坐標成功\n";
}
//對成員show()進行定義
void point::show(){cout<<"點坐標為:"<<this->x<<","<<this->y<<endl;
}int main(){point*p=new point(1,1);p.show();delete p;return 0;
}
總結
以上是生活随笔為你收集整理的C++中的双冒号(::)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Matlab实现 sift 特征匹配(代
- 下一篇: C++中const的用法