a simple gc question

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.
 
J

Jens Thiel

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.
 
G

Gideon

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top