[問題] 請問要怎麼動態增加物件(class)?
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
GCC
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include "ABC.h"
問題(Question):
請問要怎麼動態的增加新的物件(class)?
餵入的資料(Input):
Node在ABC.h裡是一個class定義.
預期的正確結果(Expected Output):
想要從一個txt檔案輸入所有物件的名稱,
並能正常建立所有物件.
錯誤結果(Wrong Output):
手動key入都正常,
但不知道怎麼動態建立...
程式碼(Code):(請善用置底文網頁, 記得排版)
void I(vector<Node*> & nodes)
{
Node * a = new Node("A");
Node * b = new Node("B");
Node * c = new Node("C");
...
nodes.push_back(a);
nodes.push_back(b);
nodes.push_back(c);
...
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 59.115.209.74
※ 文章網址: http://www.ptt.cc/bbs/C_and_CPP/M.1401179027.A.51F.html
推
05/27 16:28, , 1F
05/27 16:28, 1F
→
05/27 16:28, , 2F
05/27 16:28, 2F
→
05/27 16:43, , 3F
05/27 16:43, 3F
→
05/27 16:49, , 4F
05/27 16:49, 4F
→
05/27 16:50, , 5F
05/27 16:50, 5F
推
05/27 16:57, , 6F
05/27 16:57, 6F
→
05/27 16:58, , 7F
05/27 16:58, 7F
→
05/27 16:58, , 8F
05/27 16:58, 8F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章