Comments please

Discussion in 'C++' started by foggy, Apr 23, 2004.

  1. foggy

    foggy Guest

    class A
    {
    public:
    void methodinA();
    }

    class IFace
    {
    public:
    virtual method1()=0;
    virtual method2()=0;
    };

    class B : public IFace
    {
    A* ap;
    public:
    B(A* p) {ap = p;}
    int methodinB() { ap->methodinA(); }
    }

    Is it a good way to pass a pointer of an object of A into to make
    B::methodinB() be able to call A::methodinA()? Thanks!
     
    foggy, Apr 23, 2004
    #1
    1. Advertising

  2. foggy

    jeffc Guest

    "foggy" <> wrote in message
    news:Cm3ic.25556$...
    > class A
    > {
    > public:
    > void methodinA();
    > }
    >
    > class IFace
    > {
    > public:
    > virtual method1()=0;
    > virtual method2()=0;
    > };
    >
    > class B : public IFace
    > {
    > A* ap;
    > public:
    > B(A* p) {ap = p;}
    > int methodinB() { ap->methodinA(); }
    > }
    >
    > Is it a good way to pass a pointer of an object of A into to make
    > B::methodinB() be able to call A::methodinA()? Thanks!


    Without knowing anything more specific about your design, that is fine.
     
    jeffc, Apr 23, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Edison
    Replies:
    2
    Views:
    1,673
    Jonathan Bromley
    Jun 30, 2003
  2. KK
    Replies:
    2
    Views:
    721
    Big Brian
    Oct 14, 2003
  3. Replies:
    0
    Views:
    1,183
  4. Monk
    Replies:
    10
    Views:
    1,544
    Michael Wojcik
    Apr 20, 2005
  5. Replies:
    4
    Views:
    653
    Dr John Stockton
    Jun 3, 2006
Loading...

Share This Page