Question

I have the following structure in the code:

while (x > 0) {
     something;
     aaa::bbb::ccc some_name(
        x,
        y
     );
}

I cannot understand what aaa::bbb::ccc some_name(. If it is a call of function, why do we need to specify its time aaa::bbb::ccc. If it is a declaration of a function, why it is done in while loop and why types of the arguments are not specified?

Was it helpful?

Solution

You don't specify the return type in function calls, so this cannot possibly be a function call.

As Pubby points out, it is very likely an object definition. You define an object called some_name of type aaa::bbb::ccc and pass x and y to the constructor.

OTHER TIPS

In this particular case, it's probably constructing an object some_name of type aaa::bbb::ccc by calling its two-parameter constructor with arguments x and y.

The reason why it's done in the loop could be that the object does some useful work in its constructor and/or destructor (it could e.g. be some form of scope guard).

I am not quite sure what you are up to, but the

::

in C++ is called the scope-operator and is used to access namespaces, variables in namespaces or static class-members.

Usually function-declarations and definitions appear outside of functions and methods. So your code doesn't make any sense.

See here about the scope-operator. And here for declaration vs definition.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top