c++ - How to make array ( with a datatype of a class ) with undefined size -
my question:
i have file following:
input(1) input(2) input(3) input(6) input(7) output(22) output(23) 10 = nand(1, 3) 11 = nand(3, 6) 16 = nand(2, 11) 19 = nand(11, 7) 22 = nand(10, 16) 23 = nand(16, 19) now, read file , try find word nand. if find word nand want push id (which 10 first line) array.
problem: array in want push id of nand should of class node type. how do that?
ps: need array of node type because call method processing on 2 nodes e.g. wire(node* a, node*b);
that's easy:
include header vector:
#include <vector> declare vector, of type node:
std::vector<node> nodes; and when have created new node object:
nodes.push_back(my_new_node); also, can have vector of node* if want manage memory on own. please note, possible address of object (node) vector have careful not trust between operations on vector.
Comments
Post a Comment