Re: C programmer, what does this syntax mean?

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.

Reply to
Peter
Loading thread data ...

Which part?

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

Maybe.

Cheers, Jon

Reply to
Jon Beniston

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

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

Reply to
Peter

Hi Peter,

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

Cheers,

Ken

Reply to
Ken

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.