Search Result

Collapse
2 results in 0.0013 seconds.
Keywords
Members
Tags
forward declaration
  •  

  • ducttape
    started a topic Forward declaration in C++ not working
    in C

    Forward declaration in C++ not working

    myProgram.cpp:

    Code:
    class childClass
    {
              parentClass parent;  //reference to class that created this child
              childClass(parentClass p)
              {
                        parent = p;
              }
    };
    
    class parentClass
    {
              childClass child(this);
    };


    This would work fine in Java, which I'm more accustomed to,...
    See more | Go to post

  • Michael Sgier
    Guest started a topic forward declaration?
    in C

    forward declaration?

    Hello
    with the original code below I get the error:
    "forward declaration of `struct CPlayer'"

    class CPlayer; // what does this do? Instantiate the class CPlayer?
    // what's a forward declaration?

    class CEnemy : public CEntity
    {
    public:
    CPlayer *player;
    }

    I tried it like this which brought the error:
    "error: syntax error before `*' token"...
    See more | Go to post
Working...