Alxandr
Alxandr

Reputation: 12421

How do you define non-inline properties in C++/CLI

In C++/CLI, according to the documentation, you can define properties as such:

public ref class Vector sealed { 
public:
   property double x {
      double get() {
         return _x;
      }

      void set( double newx ) {
         _x = newx;
      }
   } // Note: no semi-colon
};

However, if you simply prototype the the property like this:

public ref class Vector sealed { 
public:
   property double x {
      double get() ;
      void set( double newx );
   } // Note: no semi-colon
};

How would you go about creating the implementation for those prototypes?

Upvotes: 2

Views: 323

Answers (1)

Alxandr
Alxandr

Reputation: 12421

In order to implement the given property x, what you need are the following 2 functions:

double Vector::x::get() {
    return _x;
}

void Vector::x::set(double newx) {
    _x = newx;
}

Upvotes: 4

Related Questions