-1

i am having problems declaring a property in C++ of array^ type.

I did it this way..

array<ref struct structname^>^ variable = gcnew array<ref struct structname^>(10);


property array<ref struct structname^>^ PROPERTY
{
array<ref struct structname^>^ get();
void set();
}

array<ref struct structname^>^ class::get()
{
return variable;
}

void class::set(array<ref struct structname^>^ x)
{
//code here
}

I get an error like this:

error C2556: 'cli::array ^namespace::class::PROPERTY::get(void)' : overloaded function differs only by return type from 'cli::array ^namespace::class::PROPERTY::get(void)'

bames53
  • 86,085
  • 15
  • 179
  • 244
Jasim Khan Afridi
  • 776
  • 3
  • 15
  • 28

1 Answers1

2

After making some assumptions and cleaning up various compiler errors, I don't end up with the compiler error you see (see my code below). If you want a better answer, you should post your actual code so that when others compile it, they will see the same error as you.

ref struct structname
{

};

ref class myclass
{
    static array<structname^>^ variable = gcnew array<structname^>(10); 

    property array<structname^>^ PROPERTY 
    { 
        array<structname^>^ get(); 
        void set(array<structname^>^ x); 
    } 
};

array<structname^>^ myclass::PROPERTY::get() 
{ 
    return variable; 
} 

void myclass::PROPERTY::set(array<structname^>^ x) 
{ 
    //code here 
}
Matt Smith
  • 17,026
  • 7
  • 53
  • 103