[問題] 標頭檔的問題
問題(Question):
無法使用 header 裡 class 的變數
錯誤結果(Wrong Output):
...does not name a type...
程式碼(Code):(請善用置底文網頁, 記得排版,禁止使用圖檔)
header file:
#include<vector>
#include<glm/glm.hpp>
class polygon {
public:
polygon() {}
polygon(std::vector<glm::vec2> vec): vertices(vec) {}
std::vector<glm::vec2> vertices;
};
_____________________________
main.cpp:
polygon cube;
^^^
這行沒問題
cube.vertices = std::vector<glm::vec2> { glm::vec2(0.0, 0.0) };
^^^
在這裡出錯 'cube' does not name a type
--
https://imgur.com/ET847SW

--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.112.235.104 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1610958791.A.65D.html
→
01/18 17:30,
4年前
, 1F
01/18 17:30, 1F
→
01/18 17:30,
4年前
, 2F
01/18 17:30, 2F
推
01/18 18:19,
4年前
, 3F
01/18 18:19, 3F
沒錯,我想用全域物件
→
01/18 19:05,
4年前
, 4F
01/18 19:05, 4F
可以請教一下為什麼原本的寫法改成加了括號的寫法就可以過編譯嗎?
→
01/18 19:06,
4年前
, 5F
01/18 19:06, 5F
※ 編輯: shiburin (140.112.235.104 臺灣), 01/18/2021 21:17:14
推
01/18 23:56,
4年前
, 6F
01/18 23:56, 6F
→
01/18 23:56,
4年前
, 7F
01/18 23:56, 7F
→
01/18 23:57,
4年前
, 8F
01/18 23:57, 8F
→
01/18 23:58,
4年前
, 9F
01/18 23:58, 9F
→
01/18 23:59,
4年前
, 10F
01/18 23:59, 10F
→
01/18 23:59,
4年前
, 11F
01/18 23:59, 11F
討論串 (同標題文章)
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章