[英]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.