One of the instance variables in my class is an object of another ref class. As far as I can tell, this works fine but I’m afraid that without explicitly calling ref new Foo(...), reference counting won’t be initialized properly. Am I right to be concerned, or am I in the clear?
Example Code
ref class Foo {
public:
Foo();
virtual ~Foo();
}
ref class Bar {
public:
Bar();
virtual ~Bar();
Foo _myNewFoo;
}
Does _myNewFoo cause a leak? Or is this fine?
Hans Passant commented on the initial question with a suitable answer: