Viewing 2 reply threads
  • Author
    Posts
    • #7092 Score: 0
      Achu
      Participant

      作业1中我使用vs2015编译,将eigen和OpenCV配置好以后运行,load_positions函数和load_indices函数报错,错误为“return”: 无法从“initializer list”转换为“rst::pos_buf_id” Assignment1 h:\computer graphic\assignment1\assignment1\assignment1\rasterizer.cpp 17 不知道该如何解决,请教各位

    • #7099 Score: 0
      Achu
      Participant

      而我将rasterizer.hpp文件中,pos_buf_id和ind_buf_id结构体中,pos_id和ind_id取消赋值反倒程序能够运行,为什么会这样子?

    • #16603 Score: 0
      CheapMeow
      Participant

      这个报错的意思是,不能列表初始化结构体。
      感觉可能是因为你使用的 C++ 版本比较旧?
      我也搜到了一些相关的描述:
      https://www.cppblog.com/jinq0123/archive/2016/12/12/214479.html

      在这里提到了在结构体中初始化错误的理由:
      https://www.geeksforgeeks.org/structures-in-cpp/

      当声明数据类型时,不会为其分配内存。仅在创建变量时分配内存。

      但是在 C++ 中是可以这么写的

      所以综合来看更像是不同 C++ 版本下的差异……?

      • This reply was modified 11 months, 1 week ago by CheapMeow. Reason: Add discription for error
Viewing 2 reply threads
  • You must be logged in to reply to this topic.