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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:26:35+00:00 2026-05-27T07:26:35+00:00

I’m sure it has been asked 100 times, but push_back is such a popular

  • 0

I’m sure it has been asked 100 times, but push_back is such a popular question that I couldn’t find an answer after searching for a long time.

My problem is that on this page it says that that a recursive push_back should work perfectly without any problem on multiple levels.

vector< vector<int> > vI2Matrix;    // Declare two dimensional array
vector<int> A, B;

A.push_back(10);
A.push_back(20);
A.push_back(30);
B.push_back(100);
B.push_back(200);
B.push_back(300);

vI2Matrix.push_back(A);
vI2Matrix.push_back(B);

However in my version I am trying to use a custom class Vector3f instead of int. I would naturally think that the following code would work, but it doesn’t. It works on the 1st level, but not on the 2nd.

vector< vector<Vector3f> > m;
vector<Vector3f> a;
a.push_back(Vector3f(1,2,3)); // <- 1st level works
m.push_back(a); // <- 2nd level doesn't

The error code returned is:

gobase.h:343: error: no match for ‘operator=’ in ‘* __result = * __first’
demo1.h:38: note: candidates are: Vector3f& Vector3f::operator=(Vector3f&)

The Vector3f class is defined in an external header file, what I am not supposed to modify. Do you think there is something missing from the given header file what makes me unable to use push_back?

The following functions are defined in the header file:

class Vector3f {
    float _item[3];

public:
    float & operator [] (int i) 
    Vector3f(float x, float y, float z) 
    Vector3f()
    Vector3f & operator = (Vector3f & obj) 
    Vector3f & operator += (Vector3f & obj) 
    bool operator ==(Vector3f & obj)
}

Update
Here is the & operator = from the header file:

Vector3f & operator = (Vector3f & obj) 
{
    _item[0] = obj[0];
    _item[1] = obj[1];
    _item[2] = obj[2];

    return *this;
};

Can you tell me how should I modify this to make push_back work?

Have a look at the complete steps required to solve this problem in GCC, I posted it as an additional answer.

  • 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-27T07:26:36+00:00Added an answer on May 27, 2026 at 7:26 am

    The assignment operator is missing from your Vector3f class. Template expansion of vector’s push_back needs an assignment operator to copy the value into the vector, so the compiler complains that it cannot find it. If you get to modify that header, you will also need to define a Vector3f(cont Vector3f& other) copy constructor.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
This could be a duplicate question, but I have no idea what search terms
Seemingly simple, but I cannot find anything relevant on the web. What is the
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has

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.