ここで次に何をすべきかを考えるのに時間がかかっています。基本的に、このプログラムはポインタ変数(*)と動的に割り当てられたメモリ(例: "int *variable = new int")以外は使用できません。私は他のすべての上に構造を作成する必要があります !
以下にいくつかのコードを含めました。すべての cin ">>" 演算子の下に赤い線があり、「エラー: 演算子 ">>" がこれらのオペランドに一致しません」というメッセージが表示されます。コードの「one.score2」部分 (最後の行) の「one」の下に赤い線があり、「エラー: 式には整数型またはスコープ外の列挙型が必要です」というメッセージがあります。
コードを機能させるにはどうすればよいですか?
#include <iostream>
#include <string>
using namespace std;
// Define structures
struct student
{
string *name;
double *score, *score2, *average;
};
void main(void)
{
// Create our students
student one, two;
cout << "Enter the first student's name: ";
cin >> one.name;
cout << endl << "Enter " << one.name << "'s first exam: ";
cin >> one.score;
cout << endl << "Enter " << one.name << "'s second exam: ";
cin >> one.score2;
one.average = ((one.score + one.score2) / 2);