Do My C++ Classes Have to be a ref class in Windows 8 Metro Style Applications?

c++, windows-8, windows-runtime

Solution

Herb Sutter recommends (12 minutes in) that you only use the non-standard C++/CX at the boundaries of your program, where your C++ code has to interact with WinRT. So that would mean that classes that you only intend to use from C++ have no need to be ref classes or use anything other than ISO standard C++.

Problem

I'm aware that if I want to share my C++ code as a WinRT component to .Net and JavaScript code I have to declare my class as `public ref MyClass sealed`. But if I have a class I just want to use within my application does it need to be a ref class? let's say I have a simple Building class. Could it be defined as follows ``` #pragma once class Building { public: Building(int cap); ~Building(void); int get_capacity() {return capacity;} private: int capacity; }; ``` and then used like this ``` std::shared_ptr<Building> bldg = std::make_shared<Building>(5); ``` I would still want to instantiate it as a shared_ptr using make_shared to get reference counting, but I'm just confused at what point I need to make it a ref class.

Original source