小编tsi*_*sid的帖子

C++谁将结构存储在堆栈中(STL)

我遇到这样的问题: 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)

怎么了?

谢谢

汤米

c++ stack struct stl

-2
推荐指数
1
解决办法
625
查看次数

标签 统计

c++ ×1

stack ×1

stl ×1

struct ×1