February 16, 2012

Example C++/CLI sealed properties and methods

This is to help remember the syntax of this stuff, it is too easy to forget
virtual void EnableStuff() sealed = IStuffEnabler::EnableStuff 
{
  stuffEnableImpl();  
}

virtual property bool IsStuffEnabled 
{
  bool get() sealed = IStuffEnabler::IsStuffEnabled::get
  {
 return stuffIsEnabledImpl();
  }
} 

Or split into source and header
Header file:
virtual void EnableStuff() sealed = IStuffEnabler::EnableStuff;
    
virtual property bool IsStuffEnabled 
{
  bool get() sealed = IStuffEnabler::IsStuffEnabled::get;
}      
and source file:
void StuffEnabler::EnableStuff() 
{
  stuffEnableImpl();  
}
    
bool StuffEnabler::IsStuffEnabled::get()  
{
    return stuffIsEnabledImpl();
}     

No comments: