空のデータ型を入力するための作業を行っています。 私は「ゲーム開発のためのC++の学習」で小さな章を何度も読んできましたが、さまざまなタイプを試しましたが、 私の問題は 列挙型の緑色を呼び出しています。ここでC++でのデータ型
は元のコードです:
#include "stdafx.h"
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int atgc, const char * arg[])
{
float classAverage = 90.7f; //Decimal number
char letterScore = 'A'; //Single letter
int testScore = 95; //Whole number value
float classTestAverage = 88.4f; //Decimal number, notice the 'f' at the end
enum class colorCode {
Green = 1,
Yellow = 5,
Red = 10
};
unsigned int gradebookColor; //Stores list of values
colorCode gradebookColor = colorCode::Green; //This line errors out bool isStudentPassing = true; //Could be true or false
cout << "The class average is currently "
<< classAverage
<< endl;
cout << "The class test average was "
<< classTestAverage
<< endl;
cout << "Your test score was "
<< testScore
<< endl;
cout << "Your current letter score is "
<< letterScore
<< endl;
cout << "The color of your gradebook entry is "
<< gradebookColor
<< endl;
cout << "Are you passing? "
<< boolalpha //This line allows the word 'true' or 'false' to be printed instead of '0' or '1'
<< isStudentPassing
<< endl;
return 0;
}
を私は色のグリーンを呼び出す方法を理解していないのです知っている:ここで
// DataTypes.cpp : The data types to declare each of the variables is missing.
// Based on the value being stored in the variable and the comments beside it,
// fill in the data type at the beginning of each line. Then compile and run
// program to make sure you selected the correct types.
//
// After you submit your answers, try changing the values stored in the
// variables. What can you learn about the different data types?
//
#include "stdafx.h"
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int atgc, const char * arg[])
{
classAverage = 90.7f; //Decimal number
letterScore = 'A'; //Single letter
testScore = 95; //Whole number value
classTestAverage = 88.4f; //Decimal number, notice the 'f' at the end
colorCode{
Green = 1,
Yellow = 5,
Red = 10
} gradebookColor; //Stores list of values
gradebookColor = Green; //This line does not need a declaration, it was declared in the line above
isStudentPassing = true; //Could be true or false
cout << "The class average is currently "
<< classAverage
<< endl;
cout << "The class test average was "
<< classTestAverage
<< endl;
cout << "Your test score was "
<< testScore
<< endl;
cout << "Your current letter score is "
<< letterScore
<< endl;
cout << "The color of your gradebook entry is "
<< gradebookColor
<< endl;
cout << "Are you passing? "
<< boolalpha //This line allows the word 'true' or 'false' to be printed instead of '0' or '1'
<< isStudentPassing
<< endl;
return 0;
}
は、私がこれまでに完了しているものです。私は本の中で示唆されている様々な組み合わせを試みたが、何も動作していないようだ。
私はこれを修正して理由を理解できるように手伝ってください。
ありがとうございます。
colorCode gradebookColor = colorCode::Green;
'colorCode gradebookColor = colorCode :: Green' – Ceros