我正在創建一個Arduino庫,它爲我的個人項目提供了兩個構造函數,但由於某種原因,我不斷收到一個類型特定的錯誤,首先讓我告訴你結構如何。所以這裏是我的文件:C++測試庫時出錯
這是頭文件:
#ifndef iGA_H
#define iGA_H
class iGA {
public:
getParameters(int soundA[], int soundB[], int parentId[]);
private:
int _soundA[];
int _soundB[];
int _parentId[];
}
cpp文件:
#include <iGA.h>
iGA::getParameters(int soundA[], int soundB[], int parentId[])
{
_soundA = soundA;
_soundB = soundB;
_parentId = parentId;
}
這該是多麼IM幾乎調用草圖中的構造,內設置()函數:
#include <iGA>
iGA iga;
void setup() {
iga.getParameters(r, r1 , r2);
}
,這裏是錯誤:
In file included from /home/bargros/Dropbox/iGA__NewBild/iGA__NewBild.ino:34:0:/home/bargros/Arduino/libraries/iGA/iGA.h:10:58: error: ISO C++ forbids declaration of 'getParameters' with no type [-fpermissive]getParameters(int soundA[], int soundB[], int parentId[]);
我知道錯誤有事情做與參數類型或者也許我調用構造函數錯誤,但我也打過電話這樣的:
iGA iga = getParameters(etc,etc,etc);
即時通訊相對較新的C++和IM有點無能至於這個錯誤告訴我什麼。有沒有人有任何想法,爲什麼發生這種情況?
你的getParameters應該返回一些東西。**提示**:**之前應該有東西** iGA :: getParameters – Incomputable
'getParameters(int soundA [],int soundB [],int parentId []);'至少應該是'void getParameters(int soundA [],int soundB [],int parentId []);'。 –
試圖添加無效,仍然得到相同的錯誤 - 將嘗試@FirstStep建議。 – Bargros