【发布时间】:2020-12-29 19:22:03
【问题描述】:
for(int i=0; i < synthesizer_->GetNotation()->size(); i++){
for(int j=0; j < synthesizer_->GetNotation()[i]->size(); j++){}
}
我想逐行显示向量的元素。
错误(在[i] 之后)是:
base operand of '->' has non-pointer type 'std::vector<std::vector<std::basic_string<char> > >'
GetNotation() 返回一个指向向量向量的指针。
我假设错误告诉我语法不正确(但我不确定)。
除了通过括号中的索引之外,我不知道如何访问包含的向量。我已经搜索过,但找不到解释或代码示例。
protected: std::vector<std::vector<std::string> > notation_;
std::vector<std::vector<std::string> >* GetNotation(){return ¬ation_;}
【问题讨论】:
-
GetNotation()返回什么? -
显示
GetNotation的返回类型。不要试图用语言来描述它,只显示函数的确切声明。 -
GetNotation() 返回一个指向向量向量的指针。
标签: c++ for-loop pointers vector size