我想知道是什麼模板,使用下面的兩個指針之間的區別:內存分配的指針和一個複製指針在模板
讓我們假設我分配的內存如下所示:
int* myPtr = new int[10];
int* anotherPtr = myPtr;
現在,我通過「myPtr」和「anotherPtr」一些功能:
doSomthing(myPtr, status);
doAnotherThing(anotherPtr, status);
上述兩個函數中,我使用這個參數來定義模板類,蘇ch爲:
tResource<int>* m_resourcePtr1;
tResource<int>* m_resourcePtr2;
m_resourcePtr1 = new tResource<int> (anotherPtr);
m_resourcePtr2 = new tResource<int> (myPtr);
resourcePtr1和resourcePtr2之間是否有區別?
不存在。 –
@Bassam你的問題背後似乎有某種原因。如果你會解釋你爲什麼問這個問題,那麼給出一個對你有意義的答案會更容易。 – selalerer