Confusing code

G

gareth

Hello all,

I've done C before but no C++. I'm looking at the example BHO at:
http://www.adp-gmbh.ch/win/com/bho.html and I'm a bit confused by some
of the code:

1. class BHO class adpbho : public IObjectWithSite, public IDispatch
{

Why are there two class declarations?

2. adpbho(unsigned long cookie) : m(1), webBrowser_(0),
connectionPointContainer(0), cookie_(cookie), document_(0) {};

I thought : was used to show the class implemented an interface.
What's it doing in the above line??

Thanks

gareth
 
G

Gavin Deane

Hello all,

I've done C before but no C++. I'm looking at the example BHO at:http://www.adp-gmbh.ch/win/com/bho.htmland I'm a bit confused by some
of the code:

1. class BHO class adpbho : public IObjectWithSite, public IDispatch
{

Why are there two class declarations?

What is BHO? Is it a macro or something? Because I can't see any other
way that can be anything other than a syntax error.
2. adpbho(unsigned long cookie) : m(1), webBrowser_(0),
connectionPointContainer(0), cookie_(cookie), document_(0) {};

That's a member initialisation list - the preferred way to initialise
bases and members in a constructor.
http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.6

Gavin Deane
 
C

Chris

gareth said:
1. class BHO class adpbho : public IObjectWithSite, public IDispatch
{

Why are there two class declarations?

According to the site, this is code for a Windows DLL? My guess is that this
isn't standard C++. Perhaps it's .NET Managed C++? MS is famous for
altering standards in order to lock users into their products (aka. vendor
lock-in).
 
G

gareth

According to the site, this is code for a Windows DLL? My guess is that this
isn't standard C++. Perhaps it's .NET Managed C++? MS is famous for
altering standards in order to lock users into their products (aka. vendor
lock-in).

There's a lot in there that seems to cause problems, even in VS.NET
2003. I think that maybe this isn't proper code, more part pseudo code
or maybe part of a larger project including a lot of macros (like #B,
MB1)

Thanks for your help

Gareth
 
J

John Harrison

gareth said:
Hello all,

I've done C before but no C++. I'm looking at the example BHO at:
http://www.adp-gmbh.ch/win/com/bho.html and I'm a bit confused by some
of the code:

1. class BHO class adpbho : public IObjectWithSite, public IDispatch
{

Why are there two class declarations?

I think it is just a mistake. Judging by the rest of the code the class
is called adpbho.
2. adpbho(unsigned long cookie) : m(1), webBrowser_(0),
connectionPointContainer(0), cookie_(cookie), document_(0) {};

I thought : was used to show the class implemented an interface.
What's it doing in the above line??

You thought wrong. The : (in this case) introduces an initialiser list,
i.e. a list of base classes and data members that are being initialised
when the constructor executes.

john
 

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

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top