Help: what statement is this?

D

daniele.g

It is a very simple statement, nevertheless it makes me confused:

pcl::OpenNIGrabber grabber (device_id, depth_mode, image_mode);

Is it a function declaration? In case, why parameters have no type declared? Is it a function call?

Any clue?

Thanks in advance.
Daniele
 
S

Stefan Ram

daniele.g said:
It is a very simple statement, nevertheless it makes me confused:
pcl::OpenNIGrabber grabber (device_id, depth_mode, image_mode);

It is an expression statement (6.2).
 
A

Alf P. Steinbach

It is a very simple statement, nevertheless it makes me confused:

pcl::OpenNIGrabber grabber (device_id, depth_mode, image_mode);

Is it a function declaration? In case, why parameters have no type
declared? Is it a function call?

Any clue?

It's a declaration of a variable (if device_id etc. are values) or a
function (if device_id etc. are types).

Assuming that it's a variable declaration:

The type of the variable is pcl::OpenNIGrabber.
The name is grabber.
The constructor arguments are device_id, depth_mode and image_mode.

Further assuming that this declaration compiles this means that the
pcl::OpenNIGrabber type is a class type that has at least one
constructor that takes 3 arguments, where the formal argument types can
accept the given arguments.

When the execution passes through the declaration the pcl::OpenNIGrabber
constructor is called with the given arguments, so the declaration
involves -- but isn't itself -- also a function call (a constructor is a
special function, and it's called here).

As a result of the constructor call an exception may be thrown here,
namely if the constructor fails.


Cheers & hth.,

- Alf
 
T

Tobias Müller

daniele.g said:
It is a very simple statement, nevertheless it makes me confused:

pcl::OpenNIGrabber grabber (device_id, depth_mode, image_mode);

Is it a function declaration? In case, why parameters have no type
declared? Is it a function call?

I guess it depends on the context.
- If device_id, depth_mode and image_mode are types, then it's a function
declaration.
- If they are variables, it's a variable declaration/definition (calling a
constructor with 3 arguments)

Maybe there are even more interpretations...

C++ is famous for such cases ;-)

Tobi
 
B

Barry Schwarz

It is a very simple statement, nevertheless it makes me confused:

pcl::OpenNIGrabber grabber (device_id, depth_mode, image_mode);

Is it a function declaration? In case, why parameters have no type declared? Is it a function call?

It appears to be a definition of an object named grabber which is of
type pcl::OpenNIGrabber with three values being passed to the
constructor.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top