:: In C++ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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.

10th Aug 2021, 8:24 AM
Yahel
Yahel - avatar
3 Answers
+ 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
10th Aug 2021, 8:44 AM
syscall
syscall  - avatar
+ 1
Thank you for the correction Odex.
10th Aug 2021, 11:17 AM
syscall
syscall  - avatar
+ 1
aka scope/ambit resolution operator if you declare a method in a header hpp, its used to define it in the cpp
11th Aug 2021, 3:49 AM
Kiwwi#
Kiwwi# - avatar