-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscope_resolution_operator
More file actions
29 lines (20 loc) · 967 Bytes
/
Copy pathscope_resolution_operator
File metadata and controls
29 lines (20 loc) · 967 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/* The double colon in the source file (.cpp) is called the scope resolution operator, and it's used for the constructor definition:
The scope resolution operator is used to define a particular class' member functions, which have already been declared. Remember that we defined the constructor prototype in the header file.
So, basically, MyClass::MyClass() refers to the MyClass() member function - or, in this case, constructor - of the MyClass class.
It is also used for accessing global variable inside every function.
global variables having global scope.that means accessible every where inside the program.
Eg
*/
:var =10( global)
var=8; (local)
For accessing global ::var
#include "MyClass.h"
MyClass::MyClass()
{
}
// a function called "test", belonging to a class "demo" WARNING NO RETURN TYPE
demo::test ()
{
}
/*
in c++ only constructors and destructors should be written without function return type - the above is a bad teaching example