tags:

views:

276

answers:

2

I am trying to do

property double Real;

and then

double Data::ComplexNumber::Real::get() {
    return _real;
}

But it is giving error. How do you go about declaring the methods in the header file and then actually implementing them? Do you use this approach in c++/cli, or you'll go the c#/vb.net way of declaring the classes and implementing right there everything?

A: 

OK, this seems to work:

Put the following in the property definition:

property double Real { double get(); set(double value) };
devoured elysium
As I recall it, your initial attempt just creates a member + a full property get/set implementation, so your implementation of Real::get would clash with the compiler-generated one.
Kim Gräsman
+1  A: 

For a simple property with get and set, you can just put this in the class definition on its own:

property double Real;

and the compiler will sort out the backing store and accessors for you.

tragomaskhalos