how to return reference in cli

  • Thread starter Zoran Stipanicev
  • Start date
Z

Zoran Stipanicev

Hi!

Does anyone knows how to get the same functionality like in
native c++ code shown below, in cli. To be more precise I don't
know what to write in place of question marks in cli code below.
Any ideas?
Thx!


//native c++
class MyClass
{
private:
int **conteiner_;
//...
int& Bridge_(int r, int c)
{
return conteiner_[r][c];
}
public:
//...
int& operator()(int r, int c)
{
return Bridge_(r, c);
}
};

//c++/cli
ref class MyClass
{
private:
array<int,2>^ conteiner_;
//...
??? Bridge_(int r, int c)
{
return conteiner_[r, c];
}
public:
//...
??? operator() (int r, int c)
{
return Bridge_(r, c);
}
};

main()
{
MyClass mc(...);
int i = mc(1,1);
}

P.S. I don't wont use property in cli, I need operator().

Best regards,
Zoran Stipanicev.
 
T

Tamas Demjen

Zoran said:
//c++/cli
ref class MyClass
{
private:
array<int,2>^ conteiner_;
//...
??? Bridge_(int r, int c)
{
return conteiner_[r, c];
}
public:
//...
??? operator() (int r, int c)

Perhaps
int% operator()(int r, int c)

To crete a reference to a managed (ref class or value) type, use the %
symbol.

Tom
 

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