我遇到这样的问题: C++:将结构存储在堆栈中
我的代码:
#include <stdio.h>
#include <stack>
#include <iostream>
#include <string>
using namespace std;
struct adresse{
string info;
};
int main(){
string eingabe;
stack<adresse> Stack1;
cout << "Bitte Ausdruck eingeben: " << endl;
getline( cin, eingabe);
adresse* temp;
temp = new adresse;
temp->info = eingabe[0];
Stack1.push(temp);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
错误是:
reference to type 'const value_type'(aka 'const adresse') could not bind to an
lvalue of type 'adresse *'Stack1.push(temp);
Run Code Online (Sandbox Code Playgroud)
怎么了?
谢谢
汤米