a simple gc question

  • Thread starter Thread starter Gideon
  • Start date Start date
G

Gideon

i understand __gc[] work different that native arrays.
say i need a __gc[] member, and a get function, that returns a ref to it.
i cant seem to make it happen.
this code:
***********CODE***********
publc __gc class Foo{
public:

Int32* get(){
return array;
};

Int32 array[];
};
**************************
gives me the following error:
error C2440: 'return' : cannot convert from 'int __gc[]' to 'int __gc *'

any ideas?

cheers,
g.
 
Gideon said:
i understand __gc[] work different that native arrays.
say i need a __gc[] member, and a get function, that returns a ref to it.
i cant seem to make it happen.

Have you considered to implement an indexer? See "Managed Extensions for C++
Specification", "13.2 Indexed Properties".

Jens.
 
I have, and it wont function the way i want it to;
Eventually, i would like to be able to do the following:

***********CODE***********
public __gc class Foo{
public:

static Int32* op_Implicit(Foo *f){
return f->array;
};

Int32 array[];
};

void main(){
Foo *f = new Foo();
Int32 i = f[0]; // implicitly conversion


}
**************************
if i use index properties, i would be able to do->
i = f->PropertyName[0];
i want to use operator[] directly on the Foo object.

thanks for your help,
g.
Jens Thiel said:
Gideon said:
i understand __gc[] work different that native arrays.
say i need a __gc[] member, and a get function, that returns a ref to it.
i cant seem to make it happen.

Have you considered to implement an indexer? See "Managed Extensions for C++
Specification", "13.2 Indexed Properties".

Jens.
 
Back
Top