相关疑难解决方法(0)

class std :: vector没有名为的成员

#include <iostream>
#include <string>
#include <vector>

using namespace std;

struct coffeeBean
{   
    string name; 
    string country;
    int strength;
};  

std::vector<coffeeBean> coffee_vec[4];

int main(int argc, char ** argv)
{
    coffee_vec[1].name;
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

当我尝试运行此代码时,我'class std::vector<coffeeBean>' has no member named 'name' 认为我们可以通过这种方式访问​​结构.难道我做错了什么?

c++ c++11

3
推荐指数
2
解决办法
7668
查看次数

标签 统计

c++ ×1

c++11 ×1