こんにちは、struct
をパラメータとして使用している問題があります。structが "仮パラメータリストの不一致"を引き起こすパラメータとして
typedef struct temps {
string name;
float max;
} temps;
私のような問題もなく私のメインでそれを使用することができます:
temps t;
t.max = 1.0;
が、このような関数のシグネチャでそれを使用して:
void printTemps(const temps& t) {
cout << t.name << endl << "MAX: " << t.max << endl;
}
私の構造体には次のようになります
それは私に次のコンパイラメッセージを与えます:
エラーC2563:構造体の
#include <iostream> #include <fstream> #include <string> #include <windows.h> #include <Lmcons.h> using namespace std; typedef struct temps { string name; float max; } temps; void printTemps(const temps& t) { cout << t.name << endl << "MAX: " << t.max << endl; } int main(int argc, char **argv) { temps t; t.max = 1.0; printTemps(t); }
任意のアイデアをいただきました!間違っている:仮パラメータ・リストここで
の不一致はMWEのですか?
C++でtypedef構造体を使用しないでください。コンパイラのエラーメッセージを表示します。 –
どのヘッダとステートメントを使用しましたか?完全な[mcve]を投稿してください。 – wally
'#include'と 'using namespace std;'を一番上に置き、g ++ 6.3.0の上に正しくコンパイルしました。 –
Luke