2012-10-20 14 views
2

在C++/CLI,according to the documentation,你可以定义属性,例如:你如何用C定义非内联属性++/CLI

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

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

但是,如果你只是原型的属性是这样的:

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

你将如何去创建这些原型的实现?

回答

4

为了实现给定的属性x,你需要的是以下2个功能:

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

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