I've been using the Boost libraries, and in Boost.Exception, I've noticed code like the following:
#define BOOST_THROW_EXCEPTION(x) ::boost::throw_exception(x)
Just out of curiosity: what is the purpose of the leading ::
before boost::throw_exception(x)
?
:: is the scope resolution operator - used to qualify names.
The call by reference method of passing arguments to a function copies the address of an argument into the formal parameter. Inside the function, the address is used to access the actual argument used in the call. It means the changes made to the parameter affect the passed argument.
A function call is an important part of the C programming language. It is called inside a program whenever it is required to call a function. It is only called by its name in the main() function of a program. We can pass the parameters to a function calling in the main() function.
Every C program has a primary function that must be named main . The main function serves as the starting point for program execution. It usually controls program execution by directing the calls to other functions in the program.
To refer to the root namespace. This is often useful if your class or you namespace uses a name which also exists in the root, but at some point you wish to refer to the root version.
For example, if I have overloaded new
in my class, but wish at some point to refer to the default (root) new
, then I would use ::new
to refer to root new.
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