Re: C programmer, what does this syntax mean?

Jan 20, 2005 4 Replies

Which part, in particular, is confusing?



"BluetoothReceiver::BluetoothReceiver() : bandpassFilter(BPLENGTH), differentiatorFilter(DIFFLENGTH) {...}" is the default constructor. The stuff after the ":" is the initialization list and may be used to initialize member objects or base class portions of a derived object.



My guess is that bandpassFilter and differentiatorFilter are both contained by BluetoothReceiver and are initialized with BPLENGTH and DIFFLENGTH upon construction.



Which part?

Probably you are refering to the part that passes arguments to the object's super-classes constructor.

Maybe.

Cheers, Jon

This is multiple inheritance and the code snippet is from the top of the code definition of the BluetoothReceiver class constructor.

The colon operator is the syntax used to call the appropriate base class constructor and this case two are being called which is multiple inheritance instead of normal, single inheritance.

Ken

Ken,

I'm not sure how you know that bandpassFilter and differentiatorFilter are inherited rather than contained by BluetoothReceiver. The initializer list syntax is valid for both data members and base classes when used in a constructor.

I suspect it is used here for data members because "bandpassFilter" is used (and not "BandpassFilter") suggesting a member, not a class. Of course the only way to be sure is to see the declarations of these identifiers.

Hi Peter,

Your reasoning sounds better than mine! I should've looked more closely since I use that naming convention myself!

Cheers,

Ken

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required