I found this line of a code in a class which I have to modify:
::Configuration * tmpCo = m_configurationDB;//pointer to current db
and I don't know what exactly means the double colon prepended to the class name. Without that I would read: declaration of tmpCo
as a pointer to an object of the class Configuration
... but the prepended double colon confuses me.
I also found:
typedef ::config::set ConfigSet;
Two colons (::) are used in C++ as a scope resolution operator. This operator gives you more freedom in naming your variables by letting you distinguish between variables with the same name.
It's called an initialization list. It initializes members before the body of the constructor executes.
Package-name::Class-name. as the name string in the name compartment. A full pathname can be specified by chaining together package names separated by double colons (::). 4.3.3 Presentation options. Either or both of the attribute and operation compartments may be suppressed.
This ensures that resolution occurs from the global namespace, instead of starting at the namespace you're currently in. For instance, if you had two different classes called Configuration
as such:
class Configuration; // class 1, in global namespace namespace MyApp { class Configuration; // class 2, different from class 1 function blah() { // resolves to MyApp::Configuration, class 2 Configuration::doStuff(...) // resolves to top-level Configuration, class 1 ::Configuration::doStuff(...) } }
Basically, it allows you to traverse up to the global namespace since your name might get clobbered by a new definition inside another namespace, in this case MyApp
.
The ::
operator is called the scope-resolution operator and does just that, it resolves scope. So, by prefixing a type-name with this, it tells your compiler to look in the global namespace for the type.
Example:
int count = 0; int main(void) { int count = 0; ::count = 1; // set global count to 1 count = 2; // set local count to 2 return 0; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With