Fehler im Programm, sagt: "Diese Datei erfordert compiler und Bibliothek-Unterstützung des ISO C++ 2011 standard"
Dieses Programm ermöglicht dem Benutzer, geben Sie Aufwendungen für jede jahreszeit und zeigt dann die Werte und dann die Gesamtkosten am unteren Rand. Es ist mir dieser Fehler jedoch
In file included from /usr/include/c++/4.8.3/array:35:0,
from main.cpp:2:
/usr/include/c++/4.8.3/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support for the \
Wie kann ich dieses Problem beheben?
#include <iostream>
#include <array>
#include <string>
//constant data
const int Seasons = 4;
const std::array<std::string, Seasons> Snames =
{"Spring", "Summer", "Fall", "Winter"};
//function to modify array object
void fill(std::array<double, Seasons> * pa);
//function that uses array object without modifying it
void show(std::array<double, Seasons> da);
int main()
{
std::array<double, Seasons> expenses;
fill(&expenses);
show(expenses);
return 0;
}
void fill(std::array<double, Seasons> * pa)
{
using namespace std;
for (int i = 0; i < Seasons; i++)
{
cout << "Enter " << Snames[i] << " expenses: ";
cin >> (*pa)[i];
}
}
void show(std::array<double, Seasons> da)
{
using namespace std;
double total = 0.0;
cout << "\nEXPENSES\n";
for (int i = 0; i < Seasons; i++)
{
cout << Snames[i] << ": $" << da[i] << endl;
total += da[i];
}
cout << "Total Expenses: $" << total << endl;
}
"Diese Unterstützung derzeit noch experimentell, und muss aktiviert werden, mit -std=c++11 oder -std=gnu++11 compiler-Optionen." Tun Sie dies.
InformationsquelleAutor B. Wilson | 2016-04-02
Du musst angemeldet sein, um einen Kommentar abzugeben.
Lesen Sie die Fehlermeldung!!! Sie benötigen zum kompilieren mit
-std=c++11
oder-std=gnu++11
.Verwenden Sie nicht
std::array
. Es ist C++11 nur. C++11 ist C++, aber (so würden Sie noch kompilieren "in c++", wenn Sie die Flagge), und deine Frage hat nichts darüber sagen wollen, vermeiden Sie die Verwendung von C++11.Vielleicht möchten Sie sich an so etwas wie cppreference.com, die deutlich darauf hinweist, Funktionen und Header, die Hinzugefügt wurden, in späteren Versionen der C++ - standard.
InformationsquelleAutor ShadowRanger