.net - c++/cli ref class and dynamic allocation using handles? -
in .net's version of c++, can declare class in following way: ref class coolclass { public: string^ getname() { return name;} void setname(string^ n) {name = n;} private: string^ name; } when create class way, instances of class created , managed on managed heap clr's garbage collector. now, lets created 2 instances of animal class. animal cat; animal ^dog = gcnew animal(); both of these classes operate same. there real important difference between creating instances of classes 1 way or other? both should managed code right? first way seems easier , prevents me having use "->" operator. the first syntax called stack semantics . simulates stack allocation in standard c++. upon leaving scope, including when exception raised, object automatically disposed. nice syntactic convenience, under hood both objects instantiated on managed heap. use first syntax disposable types only, such database connections. as d...