小编Lui*_*nes的帖子

自定义C++类上的错误

我需要帮助找到问题,使用自定义c ++类来管理3D位置.这是该课程的相关代码

  Punto operator+(Punto p){
    return Punto(this->x + p.x, this->y + p.y, this->z + p.z);
  }

  Punto operator+(Punto *p){
    return Punto(this->x + p->x, this->y + p->y, this->z + p->z);
  }

  Punto operator-(Punto p){
    return Punto(this->x - p.x, this->y - p.y, this->z - p.z);
  }

  Punto operator-(Punto *p){
    return Punto(this->x - p->x, this->y - p->y, this->z - p->z);
  }

  Punto *operator=(Punto p){
    this->x = p.x;
    this->y = p.y;
    this->z = p.z;
    return this;
  }

  Punto *operator=(Punto *p){
    this->x = p->x;
    this->y …
Run Code Online (Sandbox Code Playgroud)

c++ compiler-construction overloading operator-overloading

4
推荐指数
1
解决办法
316
查看次数

如何将std :: unordered_multimap <uint,T>转储到std :: vector <T>?

我想从一个std::unordered_multimap<uint, T> lookup到一个std::vector<T> v

到目前为止我试过了

std::vector<T> v(lookup.begin(), lookup.end());
Run Code Online (Sandbox Code Playgroud)

但它显然不起作用,因为生成的迭代器begin()end()类型pair<uint, T>,所以最快的正确方法是什么?

谢谢您的帮助!

c++ iterator stl vector c++11

4
推荐指数
2
解决办法
383
查看次数