簡體   English   中英

C ++-沒有匹配的函數可以調用<class method>

[英]C++ - no matching function for call to <class method>

我從以下代碼中獲得以下編譯器錯誤。

cube.cpp:94: error: no matching function for call to 'Animation::animate(CUBE_ARRAY&, uint8_t&, uint8_t&, CUBE_STATE&)'
animation.h:28: note: candidates are: virtual uint8_t Animation::animate(CUBE_ARRAY*, uint8_t, uint8_t, CUBE_STATE)

有一個帶有方法的Animation類:

28 virtual uint8_t animate(CUBE_ARRAY *arrayP, uint8_t transIn, uint8_t transOut, CUBE_STATE startState);

這是由行調用的:

94 animationComplete = animationPointer -> animate(cubeArray, transIn, transOut, state);

animationPointer設置為指向從Animation繼承的Raindrops類的實例:

animationPointer = &raindrops;

它的原始定義是:

Animation *animationPointer;

就我對指針的理解(有限!)而言,這應該可行: raindrops應位於animationPointer指向的地址處,然后->應該給出animate方法的結果。 因此,我不確定為什么編譯器將調用視為具有通過引用傳遞的參數。

令人困惑的是,我假設代碼非常有效(我沒有測試方法,它是嵌入式應用程序,我正在將代碼從一種MCU類型轉換為另一種MCU類型)。

錯誤消息提示您應該這樣做

animationComplete = animationPointer->animate(
    &cubeArray, transIn, transOut, state);

請注意cubeArray前面的與cubeArray

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM