Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6095911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:51:56+00:00 2026-05-23T12:51:56+00:00

So I tried to make a vector which elements are pairs of a struct

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T12:51:57+00:00Added an answer on May 23, 2026 at 12:51 pm

    nodevector.push_back(pair<node*,int>(nod1, 3));

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How do i make vector which will have pointers in it? Tried this but
I tried to make a function that takes a vector for an argument: class
I tried to make ValidationAttribute which would check the database whether such an object.
I tried to make an accordion effect with JavaScript based off this video altering
I tried to make a dynamic SQL which gets all tasks for some users
I'm writing a utility function which will take a vector of elements (could be
I want to make following code work: Mylist lst; vector<int> v = lst; So
I'm trying to make a vector drawing application using OpenGL which will allow the
Tried to make a little old school ajax (iframe-javascript) script. A bit of mootools
I tried to make an independent copy of an array but couldnt get one.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.