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

  • Home
  • SEARCH
  • 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 7863927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:37:59+00:00 2026-06-02T23:37:59+00:00

this is the code I am running: std::vector<std::vector<double>> test; test.push_back(std::vector<double>(30)); std::vector<std::vector<double> >::iterator it=test.begin(), end=test.end();

  • 0

this is the code I am running:

std::vector<std::vector<double>> test;
test.push_back(std::vector<double>(30));

 std::vector<std::vector<double> >::iterator it=test.begin(), end=test.end();
    while (it!=end) {
      std::vector<double>::iterator it1=it->first.begin(),end1=it->first.end();
      while (it1!=end1) {
    std::copy(it1.begin(),it1.end(),std::ostream_iterator<double>(std::cout, " "));
    ++it1;
      }
      ++it;
    }

this is the compilation error I get:

data.cpp:33:45: error: ‘class std::vector<double>’ has no member named ‘first’
data.cpp:33:68: error: ‘class std::vector<double>’ has no member named ‘first’
data.cpp:35:16: error: ‘class std::vector<double>::iterator’ has no member named ‘begin’
data.cpp:35:28: error: ‘class std::vector<double>::iterator’ has no member named ‘end’
data.cpp:35:34: error: ‘ostream_iterator’ is not a member of ‘std’
data.cpp:35:56: error: expected primary-expression before ‘double'

any suggestions on how to fix it so I can print the contents of test

  • 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-06-02T23:38:01+00:00Added an answer on June 2, 2026 at 11:38 pm

    I think this is more what you want.

    std::vector<std::vector<double>> test;
    // Put some actual data into the test vector of vectors
    for(int i = 0; i < 5; ++i)
    {
        std::vector<double> random_stuff;
        for(int j = 0; j < 1 + i; ++j)
        {
            random_stuff.push_back(static_cast<double>(rand()) / RAND_MAX);
        }
        test.push_back(random_stuff);
    }
    
    std::vector<std::vector<double> >::iterator it=test.begin(), end=test.end();
    while (it!=end) 
    {
        std::vector<double>::iterator it1=it->begin(),end1=it->end();
        std::copy(it1,end1,std::ostream_iterator<double>(std::cout, " "));
        std::cout << std::endl;
        ++it;
    }
    

    You don’t want first because your vector doesn’t contain pairs, and you don’t need to loop based on it1 and end1 because they denote the range you pass to copy.

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

Sidebar

Related Questions

While I am running this code it showing me a following error:- Column 'virtuemart_product_id'
Considering this code: std::vector<myObject*> veryLargeArray; for (int i = 0; i < veryLargeArray.size(); ++i)
I have this code running great in ff, opera and chrome: <script type=text/javascript> $(document).ready(function(){
I'm running this code on my datasheet subform when my form loads and I'm
I'm running this code in Firefox 11 on Windows 7. (See http://jsfiddle.net/QStkd/ ). $('<div><input
I get a segmentation fault when running this code. Anyone know why? Thanks. #include
Okay so, I'm currently running this code to move a bunch of data from
Say you want to filter elements out of a List. Running this code triggers
I'm a beginner with jdbc ... I have a problem running this code :
Following the directions at this question , I have some code running to extract

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.