开发者

visual c++ inner class as a property, possible?

开发者 https://www.devze.com 2022-12-19 00:38 出处:网络
As a C++ programmer I\'ve recently started to work with visual c++. I\'ve get stuck with the properties.

As a C++ programmer I've recently started to work with visual c++. I've get stuck with the properties.

The idea is to create an inner class that would have 2 methods plus property like get/set functions. Does it even possible in visual C++ (i guess yes).

The usage would be like this:

Foo ^ foo = gcnew Foo();
int a;
foo->Method(); // here so开发者_Python百科me function is called
a = foo; // here the property like get() function is called. 

I've even tried to do this with operator overload, but it seems that it is much more complicated in visual c++, than in "normal" c++.

MJ


This is not 'normal c++' it is native access to the .net Runtime - managed c++ (the gcnew gives this away). Do you need normal c++ on windows using visual c++ or managed c++?

If the earlier then normal c++ should work. If you need managed code - do you really need c++?

My managed c++ is poor but I think you'd need to declare get_XXX() and set_XXX() methods for this to work.

0

精彩评论

暂无评论...
验证码 换一张
取 消