devoured elysium
devoured elysium

Reputation: 105087

How to properly define properties in c++/cli in headers/body

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?

Upvotes: 2

Views: 5348

Answers (2)

devoured elysium
devoured elysium

Reputation: 105087

OK, this seems to work:

Put the following in the property definition:

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

Upvotes: 4

tragomaskhalos
tragomaskhalos

Reputation: 2753

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.

Upvotes: 2

Related Questions