tags:

views:

98

answers:

3
+3  Q: 

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

+11  A: 
vector<struct_gene *> vector_child_genes;
TheJuice
+2  A: 

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.

Greg D
+1  A: 

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.

Brian R. Bondy