Error : Class A uses Class B, which is being defin

2019-07-16 04:07发布

I have a C++ project that I've successfully wrapped with .NET classes using C++/CLI. I'm defining the wrapper classes in a .h file.

I'm currently getting Error C2460: Mixer uses Track, which is being defined.

As you can see in the code below, Mixer uses Track in the var MainTrack and Track also uses Mixer in the var Parent. How do I get these 2 classes linked to each other and compile successfully?

#ifndef CPP_MIXER_NET_H
#define CPP_MIXER_NET_H


#pragma managed



// Mixer class
public ref class Mixer {
private:
    void Create();
    void Destroy();

public:

    // props
    Track MainTrack;

    Mixer();
    ~Mixer();
    !Mixer();

};


// Track class
public ref class Track {
private:
    void Create(Track^ parent);
    void Destroy();


public:

    // props
    Mixer Parent;
    Track Parent;

    // public constructor
    Track(Track^ parent);
    ~Track();
    !Track();

};



#endif

1条回答
2楼-- · 2019-07-16 04:29

Just declare your classes at the very top:

public class Mixer;
public class Track;
查看更多
登录 后发表回答