0

How can I announce a Class before it is declared?

I think I need something like a class prototype.

Class First
{
    public:
        int Method1(Second* second); // Error: Undefined class Second
    private:
        int Attribute1;
}
Class Second
{
    public:
        int Method1(First* first);
    private:
        int Attribute2;
}

Thanks in advance.

pablo2303
  • 171
  • 1
  • 8

1 Answers1

0

What you need is forward declaration:

class Second;
class First
{
    public:
        int Method1(Second* second);
    private:
        int Attribute1;
};
songyuanyao
  • 169,198
  • 16
  • 310
  • 405