Thursday, July 30, 2009

What does it mean......... a:b::c:d ???

and,.."::" is called scope resolution operator??

What does it mean......... a:b::c:d ???
Concept:





There are two contexts involved here:





Context 1 Proportions and Analogies:





In this context a:b::c:d means , "a is to b as c is to d"





A proportion is a name we give to a statement that two ratios are equal. It can be written in two ways:





two equal fractions, a/b = c/d or,





using a colon, a:b :: c:d or a is to b as c is to d





Example : 3:5 :: 9:15





In case of Analogies we try to compare to sets of similar entities such as:





RED:COLOR::PAGE:BOOK





'Red is to Color as Page is to Book'





Context 2 C++ programming Scope Resolution:





In this context the scope resolution operator is the "::" double colon.


If you have an identifier that is the same as a global one the compiler will resolve to use the one that is in the innermost namespace. If you want to use the global identifier instead, you have to expressly say so by using the scope resolution operator:





Here is an example:





Code:





namespace mynamespace


{


void printf(char*, ...) { /*my own print function */ }





void usePrintf()


{


printf("Hello"); // will use the function defined above


::printf("Hello"); // will resolve the scope to the global printf


}


};__________________





Here is a link for additional information:





http://forums.devx.com/showthread.php?t=...





Hope the concept and explanation are helpful:
Reply:It means "a is to b as c is to d".





For example: 3:5::6:10





As a written analogy, an example might be:





cat:kitten::dog:puppy

daisy

No comments:

Post a Comment