-1
これは私の最初の質問stackoverflowですので、すべてが正しくフォーマットされていることを願っています。私はプログラミングコースの課題に取り組んでおり、2つの入力を受け取り、結果を読み取るプログラムを書く必要があります。あるコンサートに出席したいコンサートと、そのコンサートのために購入したいチケットの数を尋ねる2つの機能を作成しなければなりませんでした。関数を作成しましたが、結果を出力するために関数を呼び出すのに問題があります。C++の関数を呼び出す
#include <iostream>
using namespace std;
char GetConcert()
{
char Concert;
cout << "The following concerts are available:\n";
cout << " B for Beyonce\n";
cout << " L for Lady Gaga\n";
cout << " T for Taylor Swift\n";
cout << "Enter the letter for the concert you want:\n";
cin >> Concert;
return Concert;
}
int GetNumTickets()
{
int NumTickets;
cout << "Enter the number of tickets you want:\n";
cin >> NumTickets;
while ((NumTickets < 0) || (NumTickets > 10))
{
if (NumTickets < 0)
cout << "You can not sell tickets here.\n";
else if (NumTickets > 10)
cout << "You may not purchase more than 10 tickets.\n";
cout << "Enter the number oftickets you want:\n";
cin >> NumTickets;
}
return NumTickets;
}
int main()
{
// Declare Variables
char Concert;
int NumTickets;
// Call function to find out the concert they want to attend
// Call function to find out how many tickets they want
// Print out the information you have collected.
cout << "\nThe customer has placed the following order:\n";
cout << "Concert: " << Concert << endl;
cout << "Number of Tickets: " << NumTickets << endl;
return 0;
}
私はメインセクションに私の変数を宣言したが、私は関数を呼び出すしようとすると、それは私が文字に整数から切り替えることはできませんと言っています。
エラーを引き起こしたコードを表示してください。エラーメッセージの完全なテキストを表示します。言い換えないでください。 –
main.cpp | 40 | error: 'char(*)()'から 'int'への無効な変換[-fpermissive] | – Lumberjacked216
40行目のmain.cppにはどのようなコードがありますか? –