我如何var
或var*
類型的變量轉換爲var&
轉換從VAR到VAR和
我已經使用一個函數,它接受VAR類的對象(假設有一類)。示例代碼被賦予這樣的: -
testFunc(false, namespace1::namespace2::var(), 100);
在函數聲明
它說,第二個參數是namespace1::namespace2::var&
型的,我可以創造namespace1::namespace2::var
或namespace1::namespace2::var*
,但我如何創建namespace1::namespace2::var&
?
我知道這是太基本的問題,但我無法弄清楚。
編輯:
我只用var
試過,但它提供了一些奇怪的錯誤。我很確定這是我使用的函數中的某種錯誤。我這裏還有錯誤: -
Error 3 error C2825: 'CType': must be a class or namespace when followed by '::'
Error 4 error C2039: 'TypeCode' : is not a member of '`global namespace''
Error 5 error C2146: syntax error : missing ',' before identifier 'TypeCode'
Error 6 error C2065: 'TypeCode' : undeclared identifier
Error 7 error C3203: 'CustomType' : unspecialized class template can't be used as a template argument for template parameter 'Base', expected a real type
編輯2
我想那會很難回答,如果我有真正的代碼,因爲它很複雜。但看看它是否有幫助。真正的函數的簽名是這樣的: -
virtual bool opRaiseEvent(bool reliable, const Common::Hashtable& parameters, nByte eventCode, nByte channelID=0, int* targetPlayers=NULL, short numTargetPlayers=NULL);
和示例代碼中使用的功能如下: -
mLoadBalancingClient.opRaiseEvent(false, ExitGames::Common::Hashtable(), 100);
這是工作的罰款。但是現在我想向HashTable添加數據,所以我需要創建它的一個對象,然後將它傳遞給函數。它不接受指針或正常變量。我不知道它爲什麼只用HashTable()。
什麼是你試圖調用油膏的簽名? – TeaOverflow
請給我們一些真實的代碼。 – fefe
現在你添加了真正的錯誤,也許你也可以添加真實的代碼:你的錯誤談論'CType'和'CustomType';沒有提及'namespace1'或'var'。 – dasblinkenlight