+14

Working of Scope Resolution Operator( : : )?

4/11/2019 4:02:45 PM

Prachi

7 Answers

New Answer

0

Any varible has its own scope. for example... int x = 3; //global scope int numberX () { int x = 10; return x; } //scope of this function class NummerX { private: int x = 666; //scope of the class public: getX() { return x} } .... In the main() , you could call all 'x' variable unumbigously beacause each 'x' is applied in a scope. the operator :: changes the scope in question... Have you got? scope means +-: for each 'x' the compiler pick up the more suitible according to the context

+5

I didn't get your question. Can you clarify it more. For now I got this for you https://www.tutorialspoint.com/Scope-resolution-operator-in-Cplusplus

+5

You can use this for get variable in static class, make "body" of method, etc., e.g.: class A { void method(); }; void A::method() { cout << "method();"; }

0

printf() is in C. C++ use cout . Printf wold be compiled by C++ compiler, but avoid this as you can.

-1

Why don't(can't) we learn print f in this app?

-1

-1

I am new here