kurrata
kurrata

Reputation: 107

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

Upvotes: 3

Views: 628

Answers (3)

Brian R. Bondy
Brian R. Bondy

Reputation: 347216

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.

Upvotes: 1

Greg D
Greg D

Reputation: 44066

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.

Upvotes: 3

TheJuice
TheJuice

Reputation: 4484

vector<struct_gene *> vector_child_genes;

Upvotes: 11

Related Questions