#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'
认为我们可以通过这种方式访问结构.难道我做错了什么?