What does "::" mean?

0 Dylan Dawson · May 3, 2015
Hi i'm upto tutorial 42, and I still don't exactly know what :: means.
I know that if you put it in fornt of a variable it will chose the global one instead of  the local one.
But i dont know what it means if you deal withe classes e.g

Post a Reply

Replies

Oldest  Newest  Rating
0 Arne Magnus Lorentzen Ulland · May 3, 2015
Hey Dylan!

Lets say you have a class like this:

class DYLAN {

     public: 
               void dylansFunction(int a);
 };

And another class like

class STRANGER {

     public: 
               void dylansFunction(int a);
 };

in the cpp file (the file you write your code), you want to use dylansFunction.

How to know if you are using dylansFunction from the class DYLAN or STRANGER?
Answer: 

DYLAN::dylansFunction(int a)
Thats like saying "hey, i want to use dylansFunction from the class DYLAN. 
0 Dol Lod · May 3, 2015
Arne is right given this context.

However, given the title asking what "::" means, I would like to add that it is also used in extended for loops which allow you to iterate through an array, making it easier to use individual element in an array instead of always using a fixed size. 
0 Dylan Dawson · May 5, 2015
Yeah I wish I could delete comments almost 2 mins after I posted I found out what it meant but thanks for the help anyway!:D
  • 1

C++

107,224 followers
About

Used in many types of software including music players, video games, and many large scale applications.

Links
Moderators
Bucky Roberts Administrator