Some COM pointers in the Inventor API have two versions of the same function. For example
// Get the list of rectangular features CComPtr<RectangularPatternFeatures> pRectPatList ; pFeaturesList->get_RectangularPatternFeatures (&pRectPatList) ; pRectPatList->Add (...) pRectPatList->MethodAdd (...)
What is the difference between Add and MethodAdd?
Solved! Go to Solution.
Solved by philippe.leefsma. Go to Solution.
Every COM C++ Inventor API method come in 2 flavors:
- low level methods: that take output param as input and return HRESULT
- high level methods: that return the result directly and throw exceptions
high level methods are *usually* prefixed "Method".
Regards,
Philippe.
______________________________________________________________
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
So this is the same difference as is between
hRes = get_Blah...
and
BlahPtr = GetBlah()
?
And in both cases, when I get a pointer should I set it to NULL after use not to have memory leaks?
Yes that's correct. Concerning pointers, this is a good practice to set them to NULL if not needed anymore, however if working with smart pointers, they should release their COM object as they are going out of scope. The Inventor SDK has several C++ samples, this is a good place to get started.
Regards,
Philippe.
Thanks for the clear reply.
"The Inventor SDK has several C++ samples, this is a good place to get started."
Unfortunately the C++ samples are very few compared with VB examples and they vary in quality.
In some of the C++ examples the pointers are set to NULL, in others not.
I see I still have much to learn!