Aug 24, 2018 at 9:52pm Aug 24, 2018 at 9:52pm UTC
Hi Friends,
Im trying to Compile this Code
But i get always the error Massage.
HilfsZeiger freund and nullptr were not declared
Error Massage :: not declared in this scope.
Im really thankful for every help.
using namespace std;
struct WoW_t {
string klasse;
string nickname;
unsigned int freund_seit;
WoW_t *next;
};
int main()
{
int wahl;
WoW_t *anfang = nullptr, *hilfsZeiger, *freund;
do{
cout << "-1- Freund hinzufügen\n";
cout << "-2- Freunde ausgeben\n";
cout << "-3- Beenden\n";
cout << "Deine Wahl: ";
cin >> wahl;
switch(wahl)
{
case 1:
freund = new WoW_t;
cout << "Klasse : ";
cin >> freund->klasse;
cout << "Name : ";
cin >> freund->nickname;
cout << "Verbund : ";
cin >> freund->freund_seit;
if(anfang == nullptr)
{
anfang = freund;
freund->next = nullptr;
}
else
{
hilfsZeiger = anfang;
while(hilfsZeiger->next != nullptr)
{
hilfsZeiger = hilfsZeiger->next;
}
hilfsZeiger->next = freund;
freund->next = nullptr;
}
break;
case 2:
cout << "Deine WoW-Freunde\n\n";
hilfsZeiger = anfang;
while(hilfsZeiger != nullptr)
{
cout << "Klasse : " << hilfsZeiger->klasse;
cout << "\nName : " << hilfsZeiger->nickname;
cout << "\nVerbund: " << hilfsZeiger->freund_seit << endl;
hilfsZeiger = hilfsZeiger->next;
}
break;
}
}while(wahl != 3);
return 0;
}
Aug 24, 2018 at 10:38pm Aug 24, 2018 at 10:38pm UTC
The code that you have posted does compile without errors or warnings.
Aug 25, 2018 at 12:25am Aug 25, 2018 at 12:25am UTC
You are probably compiling it as C++98 which doesn't know "nullptr". Either change nullptr to 0 or compile it as C++11. If you're using gcc you can pass the flag: -std=c++11