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. A have been searching for this all day and I couldn’t find anything. You solved my problem. Thank you very much. ^_^

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s