没有可用于结构向量的成员
No members available for a vector of structs
我有一个名为Heap的模板类。我的问题是,我想在底部实现insert函数。但是我无法到达Values向量的成员变量。当我写Values[hole/2].tall时,它无法到达它(tall变量不会直接出现在写点之后)。有人能解释一下吗?
template <class Comparable>
class Heap
{
...
private:
// I have this vector
vector <heightNode <Comparable>> Values
};
template <typename Comparable>
struct heightNode
{
Comparable tall;
Comparable label;
heightNode(const Comparable & t = Comparable(), const Comparable & la = Comparable()): tall(t),label(la) {}
heightNode(const heightNode & rhs): tall(rhs.tall),label(rhs.label){}
};
template <class Comparable>
void Heap <Comparable>:: insert (const Comparable & value, const int & label)
{
if(isFull())
{
cout <<"Heap is Full";
}
else
{
++currentSize;//hole is an index we will put it to the last point in the vector.
for(int hole=currentSize; hole>1 && (value > Values[hole/2].tall)); hole/=2 )
{
}
}
}
此
for(int hole=currentSize; hole>1 && (value > Values[hole/2].tall)); hole/=2 )
包含一个多余的圆形闭合支架;使其成为
for (int hole=currentSize; hole>1 && (value > Values[hole/2].tall); hole/=2)
相关文章:
- 向量成员在管理类指针C++队列时丢失
- C++:更新类的向量成员变量
- C++ 入门 12.1:我可以在类中使用静态向量成员实现 StrBlob<string> 吗?
- 具有向量成员的基类<int>
- C++ 向量::使用类对象迭代器擦除不擦除向量成员
- 无法将类构造函数中新创建的对象复制到 C++ 中的向量成员
- 修改另一个类的向量成员时出错
- 返回对私有向量成员元素的非常量引用是否是一种不好的做法
- 如何在 C++ 中将结构类型向量数据输入到结构向量成员(嵌套结构向量)中
- std::向量成员变量 EXC_BAD_ACCESS
- 如何使用其定义附近的显式长度/值构造函数初始化向量成员变量
- "Empty"数组\向量成员 C++
- 如何使用初始值设定项列表初始化 2D 向量成员
- 如何在类定义中初始化向量成员变量
- 如何初始化结构的向量成员
- 使用向量<向量>成员实例化对象时的隔离错误<int>
- 为向量成员和更新元素指定默认值
- 保持类的向量成员与类实例连续
- C++:在类构造函数中填充向量后,向量成员被销毁
- 通过引用另一个类方法传递向量成员变量