Domanda

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
È stato utile?

Soluzione

Just declare your classes at the very top:

public class Mixer;
public class Track;
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top