简体   繁体   中英

c++ vector pointer

How do i make vector which will have pointers in it? Tried this but failed.

vector<*struct_gene> vector_child_genes;

full code if some one is interested http://codepad.org/50qrNZvd

vector<struct_gene *> vector_child_genes;

Try something like this:

vector<struct_gene*> vector_child_genes;

You specify a type in the angle brackets of the vector, and pointer types are specified with a postfix asterisk, not a prefix asterisk.

You put the type inside the brackets. There is no special syntax otherwise. If you normally declare a pointer with a * after the type (I hope so) then you still do that same thing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM