1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Forward declaration Doubt

Discussion in 'C' started by majesticmanish, Apr 1, 2009.

  1. majesticmanish

    majesticmanish New Member

    Joined:
    Dec 24, 2008
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    I have a doubt regarding forwarding declaration.

    in .h file:
    class B;
    class A{
    void func(B* tap);
    }

    in .cpp file
    void A::func(B* tap){
    tmpo=tap->par1;
    }

    does the above code snipet correct if not whats the problem. Please be descriptive.
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,285
    Likes Received:
    364
    Trophy Points:
    83
    In .cpp file I assume you have included the .h file and if that is true its correct but then tmpo and other variables are in doubt
     
  3. Mridula

    Mridula New Member

    Joined:
    Mar 5, 2008
    Messages:
    316
    Likes Received:
    19
    Trophy Points:
    0
    Occupation:
    S/w proffessional
    Location:
    Bangalore
    You need have to include the .h file for declaration for class A in the file where "class B" declaration is there.
    Apart from that tempo is what here?
     
  4. majesticmanish

    majesticmanish New Member

    Joined:
    Dec 24, 2008
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    I got my doubt clear. I have to include B.h file in A.cpp file as earlier i was in a doubt since i already had made forward declaration of B in A's header file.

    tempo is nothing imp. here....just a part of rough-code.

    btw, thanks 4 clearing my doubt.
     

Share This Page