How to correctly define properties in C ++ / cli in headers / corpus

I am trying to do

property double Real;

      

and then

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

      

But this gives an error. How do you start by declaring methods in your header file and then actually implementing them? Are you using this approach in C ++ / cli, or will you use the C # / vb.net way to declare classes and implement everything there?

+2


source to share


2 answers


OK, this works:

In the property definition, enter the following:



property double Real { double get(); void set(double value); }

      

+4


source


For a simple property with get and set, you can simply put this in the class definition yourself:

property double Real;


and the compiler will sort the storage and accessors for you.

+2


source







All Articles