Confusing code

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • gareth

    Confusing code

    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),
    connectionPoint Container(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

  • Gavin Deane

    #2
    Re: Confusing code

    On 19 Feb, 14:31, "gareth" <garethricharda d...@gmail.comw rote:
    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),
    connectionPoint Container(0), cookie_(cookie) , document_(0) {};
    That's a member initialisation list - the preferred way to initialise
    bases and members in a constructor.


    Gavin Deane

    Comment

    • Chris

      #3
      Re: Confusing code

      gareth wrote:
      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).

      --
      Chris

      Comment

      • gareth

        #4
        Re: Confusing code

        On 19 Feb, 15:29, Chris <c...@thisisnot anemailaddress. cawrote:
        gareth wrote:
        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).
        >
        --
        Chris
        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

        Comment

        • John Harrison

          #5
          Re: Confusing code

          gareth wrote:
          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),
          connectionPoint Container(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

          Comment

          Working...