Splitting a C++/CLI property’s definition and implementation into separate cpp/header files

I got asked this in one of my article forums, and thought I’d blog about it here so I can just direct people to a single URL if the question comes up again. Here’s how you’d do it (I used the example property the OP used):

//The header file

ref class Test
{
public:
  property Byte default[int]
  {
    Byte get(int index);
    void set(int index, Byte value);
  }

  //...
};

//The cpp file

Byte Test::default::get(int index)
{
  return 0;
}

void Test::default::set(int index, Byte value)
{
}

//...

3 thoughts on “Splitting a C++/CLI property’s definition and implementation into separate cpp/header files

  1. Thank god.. i have been searching more 2 days for this.. with the key words “coding practices for C++/CLI”

    Thank u

  2. A have been searching for this all day and I couldn’t find anything. You solved my problem. Thank you very much. ^_^

Leave a comment