then I've got a class that includes a Then the source file in the file However the problem is that I can not use Obviously Actually I'm counting on a function with which to give me an indicator I can use somewhere else. However, the function allocates on the stack rather than the pile. Is there a special way to solve this problem, perhaps with a double pointer? Or do I just have to call the When you call Usually, this will be std :: unique_ptr like this:.
class objectA {public: object A (); ~ ObjectA (); Some functions (); Private: std :: unique_ptr & lt; ObjectB & gt; MyPointer; } in myPointer is used in the manufacturer and used in SomeFunction () .
Object A: Object A () {Object Object C; MyPointer = std :: move (std :: unique_ptr myFoinction in myFoinction () , and why here. myPointer should be allocated on a heap to make sure it is not that the constructor will be destroyed if executed. Assume that ObjectC and the resultant functions are from external libraries when I call ObjectC :: getPointer () , then pointer to be allocated on a heap of piles Is allocated. Now I think this is the case because after getting the correct execution of the producer, I get an error has ended. ObjectC :: getPointer () , every time I want to use the pointer inside each performance block? If I have many functions inside ObjectA , which depends on myPointer, then ObjectC :: getPointer () per function is useless, but I Don does not know that there is a better way to fix it, and I feel like a function ( ObjectC :: getPointer () ) that I should not force that redundancy. ObjectC :: getPointer () You just do not get the "a" indicator function should specify how well the operation pointer is, and how specifically it should be disposed of. delete , but this can also be an example fclose . You have to read the documentation. If the returned indicator matches the life of objectC , then the life of objectC must match the myPointer . So it should probably be a member, and in turn it means that myPointer can be unnecessary just you private option: objectb & amp; GetB () {Return * myObjectC.GetPointer (); }
No comments:
Post a Comment