+ 1
:: In C++
Hi, what does :: (double colon) mean in C++? Iv'e seen it when you type std::cout (for namespace usage...), for implementing a class method outside of a class, std::this_thread::sleep_for(...), etc... what is the exact defenition of when you use it and what does it do? Thanks.
5 ответов
+ 4
(edited- corrected a few things)
:: is scope resolution operator, its just c++ syntax, language rules you have to follow. As its name suggests it is used to resolve scope issues.
it is usually used to access the namespaces from the files you included at the top.
so if u have a cout function in ur #include “cus.h” with cus namespace : if u will use
cus::cout
it will access ur custom cout function
std::cout
to use standard library cout function
+ 1
Thank you for the correction Odex.
+ 1
aka scope/ambit resolution operator
if you declare a method in a header hpp, its used to define it in the cpp