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 6875547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:20:40+00:00 2026-05-27T04:20:40+00:00

In my program, I have a vector of vector of ints. Now I want

  • 0

In my program, I have a vector of vector of ints. Now I want to take one vector from the vector of vectors and have it manipulated in another vector container, but I get the error…

|error: conversion from '__gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >' to non-scalar type 'std::vector<int, std::allocator<int> >' requested|

An example of what I am trying to do is as follows….

#include <vector>
using namespace std;

vector<vector<int> > k (13,5);

void some_funct() {
    vector<int> new_v (k[2].begin(), k[2].end());  //This line is what throws the error
    //here I do some stuff with new_v (e.g. sort it)
}

I’m not sure what I am doing wrong. I tried a couple of things like assigning the begin() and end() iterators to const iterator types… vector<int>::const_iterator it = k[2].begin(); but that didn’t work either.

This should work (because k[x] would be a vector) but I don’t know what is going wrong. Any help is appreciated!

EDIT:

After revision of my code, I noticed that there actually was an error. Instead of doing vector<int> new_v (k[2].begin(),k[2].end()); I did vector<int> new_v = (k[2].begin(),k[2].end());.

I would like to thank Rob for giving me the initiative to copy and paste my code into SO, where I noticed my mistake.

Thank you for your help!

  • 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-27T04:20:41+00:00Added an answer on May 27, 2026 at 4:20 am

    It is hard to know, because you haven’t posted your actual code into the question. I suspect that you mis-copied the code from your project into Stack Overflow.

    The offending line in your project looks something like this:

    vector<int> new_v = (k[2].begin(), k[2].end()); 
    

    Note the extra =.

    You are initializing new_v with an expression of type vector::iterator, which won’t work. The statement you typed into SO, however, will work:

    vector<int> new_v (k[2].begin(), k[2].end()); 
    

    As will this:

    vector<int> new_v = vector(k[2].begin(), k[2].end());
    

    Or either of these:

    vector<int> new_v(k[2]);
    vector<int> new_v = k[2];
    

    See https://ideone.com/uK8Xg and the corresponding error message.

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

Sidebar

Related Questions

I have a program and I want to take a command line argument of
I have a Vector < String >. Now i want to store those Strings
I have a program that draws some vector graphics using System.Drawing and the Graphics
I have created a vector of sets in my program, and I need to
Basically I have a part of my program (it's for Vector solving) that is
Possible Duplicate: Is stl vector concurrent read thread-safe? I have a multi-threaded program that
I have program that requires Python 3, but I develop Django and it uses
I have program that runs fast enough. I want to see the number of
I'm working with vector now and I have an interesting situation which I need
Say I have a vector which holds pointers pointing to dynamic memory but also

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.