Scope resolution operator is resolved to unhide the scope of a global variable.
for eg:
#include<iostream.h>
int x=20; //global variable
void main()
{
int x=10; //local variable
cout<<x;
}
output will be 10 only. you will never get the answer as 20. local and global variable are having the same name(here x). so unhide the scope of the global variable you have to use a scope resolution operator(::) before the variable.
so if you are changing the above code as :cout<<::x; you will get the answer as 20.
The only "special" operators in C++ are those that cannot be overloaded. That is; the dot member operator (.), pointer to member operator (.*), ternary conditional operator (:?), scope resolution operator (::), sizeof() and typeof().
There are 5 operators which cannot be overloaded. They are: * .* - class member access operator * :: - scope resolution operator * . - dot operator * ?:: - conditional operator * Sizeof() - operator Note:- This is possible only in C++.
In C we use & operator while giving address of some variable to some pointer variable. & operator is also used in scanf().
C is not an object-oriented language -- there are no destructors. In C++, however, an object's destructor is invoked automatically when the object falls from scope. The destructor can also be invoked by manually deleting a raw pointer to the object (or one of its base classes), however you should only ever use the delete operator if the object was instantiated with the new operator, and only after all references or pointers to the object have fallen from scope. The safest way to manage raw pointers is to use a resource handle or smart pointer.
The if statementex.if (index < 5)printf("Index is less than 5\n");elseprintf("index is greater or equal to 5\n");(You can also replace the "if" with a "?" and the "else" with a "?" -- no, that would be syntax error)
:: operator can not be used in C.
No.
You use the scope resolution operator (::) whenever there is ambiguity as to which function or member you are referring to. For instance, if two functions in two separate namespaces have the same signature, you must use scope resolution to call the correct version of the function. Similarly, when calling a base class method from a derived overridden method, you must use scope resolution to ensure the base class method is called from the override.
The only "special" operators in C++ are those that cannot be overloaded. That is; the dot member operator (.), pointer to member operator (.*), ternary conditional operator (:?), scope resolution operator (::), sizeof() and typeof().
1. Member-of operator (.) 2. Pointer-to-member-of operator (.*) 3. Ternary condition operator (?:) 4. Scope resolution operator (::) 5. sizeof operator 6. typeid operator
There are 5 operators which cannot be overloaded. They are: * .* - class member access operator * :: - scope resolution operator * . - dot operator * ?:: - conditional operator * Sizeof() - operator Note:- This is possible only in C++.
Scope resolution is not required in C because C does not support namespaces. All non-local names are declared in the global scope.
A hidden global variable must be one that has its scope blocked by a local variable of the same name. To access the hidden variable, use the scope resolution operator ::, such as is ::variable_name. If there is another reason for the hidden status, please clarify and restate the question.
conditional operator , size of operator , membership operator and scope resulation operator can not be overload in c++
There is no memory management operator in C++ -- it is an unmanaged language. You use the C++ new operator to allocate memory, and use the C++ delete operator to release previously allocated memory.
In C we use & operator while giving address of some variable to some pointer variable. & operator is also used in scanf().
Scope resolution allows the programmer to disambiguate between names that are common to two or more namespaces. For instance, if you imported two namespaces that both exposed different string classes, the compiler would not know which string class to use unless you use scope resolution to differentiate them. Scope resolution can also be used to differentiate between the different function overrides within a class hierarchy. By default, the most-derived function override is always executed implicitly, but that override may choose to invoke one or more of its base class overrides using scope resolution. struct a { virtual void foo() {/*...*/} }; struct b : a { virtual void foo() override; }; void b::foo() { a::foo(); // explicitly invoke base class method using scope resolution. // ...specialisation code goes here... }