The usage of :: in C++

This is the scope, if you want to reference a static member function outside the class, or define a member function outside the class. Use the types or functions in the namespace (such as: std::cout, std::cin, std::string, etc.)

Instance

class Test{
public:
    Test();
     static void print() 
    {
        std::cout<<"Test"<<endl; //命名空间时使用::
   }
private:
     int a;
};
Test::Test() : a(1)   //定义时使用::
{}
Test::get();  //使用静态成员函数时用::

 

Undertake programming in Matlab, Python and C++, machine learning, computer vision theory implementation and guidance, both undergraduate and master's degrees, salted fish trading, professional answers please go to know, please contact QQ number 757160542 for details, if you are the one.

 

 

 

 

 

 

 

Guess you like

Origin blog.csdn.net/weixin_36670529/article/details/115053486