Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Help: what statement is this?

50 views
Skip to first unread message

daniele.g

unread,
Nov 15, 2013, 11:21:52 AM11/15/13
to
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
Message has been deleted

Victor Bazarov

unread,
Nov 15, 2013, 11:31:44 AM11/15/13
to
On 11/15/2013 11:25 AM, Stefan Ram wrote:
> "daniele.g" <gigl...@gmail.com> writes:
>> 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).

Looks more like a declaration statement to me.

V
--
I do not respond to top-posted replies, please don't ask
Message has been deleted

Alf P. Steinbach

unread,
Nov 15, 2013, 11:54:14 AM11/15/13
to
On 15.11.2013 17:21, daniele.g wrote:
> 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

Drew Lawson

unread,
Nov 15, 2013, 11:58:27 AM11/15/13
to
In article <fc25b057-ab10-487b...@googlegroups.com>
"daniele.g" <gigl...@gmail.com> writes:
>It is a very simple statement, nevertheless it makes me confused:
>
>pcl::OpenNIGrabber grabber (device_id, depth_mode, image_mode);

Others posts answered, but didn't seem to help.

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

It is a declaration of a (probably) class instance variable (aka
an object). The variable name is "grabber" and the type is
"pcl::OpenNIGrabber" . The list in parentheses are arguments to
the object's constructor, which makes it a little like a function
call.

Most likely, this is an instance of the class OpenNIGrabber, and
that class is in the namespace pcl. (Google suggests that is Point
Cloud Library, whatever that is.)


>Any clue?
>
>Thanks in advance.
>Daniele


--
| Stories of tortures used by debauchers
Drew Lawson | lurid, licentious and vile
| make me smile

Tobias Müller

unread,
Nov 15, 2013, 12:13:10 PM11/15/13
to
"daniele.g" <gigl...@gmail.com> wrote:
> 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

Barry Schwarz

unread,
Nov 15, 2013, 12:16:00 PM11/15/13
to
On Fri, 15 Nov 2013 08:21:52 -0800 (PST), "daniele.g"
<gigl...@gmail.com> wrote:

>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.

--
Remove del for email
0 new messages