このエラーを受け取り続けるには、このコードで何が問題になりますか?cout/cinは型エラーの名前を付けません
エラーは、mainに「distanceFormula」を入れるのではなく、私はそれを自分のクラスにしました。
#include <iostream>
#include <string>
using namespace std;
class distanceFormula {
public:
int speed;
int time;
int distance;
cout << "What is the speed?" << endl;
cin >> speed;
cout << "How long did the action last?" << endl;
cin >> time;
distance = speed * time;
cout << "The distance traveled was " << distance << endl;
};
int main()
{
distanceFormula ao
ao.distanceFormula;
return 0;
};
なぜあなたは独自のクラスを作ったのですか?あなたはあなたのコードをコンパイルしましたか? –
関数とクラスを区別します。 –
'ao.distanceFormula;'それは何をするはずですか? – drescherjm