So I tried to make a vector which elements are pairs of a struct pointer and an int, and I'm beginning to think that this may be impossible..
Suppose I have the following struct:
struct node{
string str;
int size;
node *child[3];
node(string str1):str(str1){ size = 0;}
};
and a vector:
vector< pair<node*,int> > nodvector;
Then I tried to make a new node and put it in the vector, and apparently it's not working:
int main(){
node* nod1 = new node("HELLO");
node* nod2 = new node("WORLD");
nodevector.push_back(pair<nod1,3>);
delete nod1;
delete nod2;
}
The compiler barks at me saying: nod1 cannot appear in a constant-expression error: template argument 1 is invalid error: type/value mismatch at argument 2 in template parameter list for template struct std::pair
Is this just something impossible? What could be an alternate solution to this? Your input will be so much appreciated!
nodevector.push_back(pair<node*,int>(nod1, 3));