こんにちは、私の C++ コードにエラーがあります。2 つの .cpp ファイルと 1 つの .h ファイルがあり、ヘッダー ファイルから 5 つの文字列と 1 つの int にアクセスしようとしていますが、「明示的な型がありません ('int' と見なされます)」というエラーが表示されます。
他にもいくつかエラーがあります。異なる基本型、オーバーロードされた関数は戻り値の型のみが異なり、宣言は互換性がありません。
ここに私のファイルがあります:
UserChoice.h
#include <iostream>
#include <string>
using namespace std;
#ifndef USERCHOICE_H
#define USERCHOICE_H
class Shops
{
public:
double Items(string, string, string, string, string, int);
int main()
{
std::cout << newItem1;
}
private:
string newItem1;
string newItem2;
string newItem3;
string newItem4;
string newItem5;
int newItems;
};
#endif
アイテム.cpp
#include "UserChoice.h"
Shops::Items(string Item1, string Item2, string Item3, string Item4, string Item5, int Items)
{
newItem1 = Item1;
newItem2 = Item2;
newItem3 = Item3;
newItem4 = Item4;
newItem5 = Item5;
newItems = Items;
}
ソース.cpp
#include "UserChoice.h";
#include <string>
int main()
{
string Item1;
string Item2;
string Item3;
string Item4;
string Item5;
int items;
std::cout << "What what you like? Chicken, Meat, Fish, Carrot or Apple?\n";
std::cin >> Item1;
std::cout << "\nAnything else?\n";
std::cin >> Item2;
if(Item2 == "nothing else")
{
}
std::cout << "\nAnything else?\n";
std::cin >> Item3;
std::cout << "\nAnything else?\n";
std::cin >> Item4;
std::cout << "\nAnything else?\n";
std::cin >> Item5;
std::cout << "\nAnything else?\n";
}
エラーライン
Shops::Items(string Item1, string Item2, string Item3, string Item4, string Item5, int Items)
すべてのコードはまだ完成していないので、これらのエラーを見つけて修正するのを手伝ってくれることを願っています. 事前に感謝します。さらに情報が必要な場合は、私に尋ねてください。