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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:08:04+00:00 2026-05-18T11:08:04+00:00

I am having trouble filling a vector of type vector<vector<clickable> > . The compiler

  • 0

I am having trouble filling a vector of type vector<vector<clickable> >. The compiler seems to be ok with pushing back vector<clickable> onto it as long as the push_back happens in the same function as the declaration of the variable, but it doesn’t allow it when the variable is declared in a .h file and the push_back is executed in another function of the class.

In the following examples, the loops should be exactly the same, except that one calls push_back on a vector<vector<clickable> > that was just declared in the same function, and the other calls push_back on one declared in the .h file.

Example of what works (This is from the main function, but it works in any function.):

vector<vector<clickable> > clicks;
for(int i = 0; i < 10; i++){
    vector<clickable> click;
    for(int j = 0; j < 10; j++){
            click.push_back(clickable(Rect(Point(50,50),5,10),"blar"));
    }
    clicks.push_back(click);
}

Example of what doesn’t work:

Gui.h:

#include <vector>
//...
struct clickable {
    Rect rect;
    string msg;
    bool visible;
    clickable(Rect rectangle, string message){
            rect = rectangle;
            msg = message;
            visible = true;
    }
};
//...
class Gui{
  public:
    //...
    void load_environment();
    //...
  private:
    vector<vector<clickable> > ship;
    //...
}

Gui.cpp:

#include "Gui.h"
//...
void Gui::load_environment(){
    for(int i = 0; i < 10; i++){
            vector<clickable> click;
            for(int j = 0; j < 10; j++){
                    click.push_back(clickable(Rect(Point(50,50),5,10),
                                            "blar"));
            }
            ship.push_back(click);
    }
}
//...

I think it might have something to do with my failure to overload some operators, but I don’t actually have any idea if that is even the cause of the problem, or what I should overload if it is.

edit
Here is the text of the error:

Gui.cpp:47: error: no matching function for call to ‘std::vector<std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, std::allocator<std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > >::push_back(std::vector<clickable, std::allocator<clickable> >&)’
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:602: note: candidates are: void std::vector<_Tp, _Alloc>::push_back(const _Tp&) [with _Tp = std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, _Alloc = std::allocator<std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >]

  • 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-18T11:08:04+00:00Added an answer on May 18, 2026 at 11:08 am

    The error message says, in effect, that it thinks the vector you’re trying to push_back onto is actually a vector<vector<string> >, rather than a vector<vector<clickable> > as you were expecting.

    You probably just need to do a clean rebuild.

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

Sidebar

Related Questions

I'm having trouble with a WebView always filling the full screen and thus covering
Having trouble linking the Stomp.framework into an iPhone SDK application. http://code.google.com/p/stompframework/ I follow the
Im having trouble using a .NET COM in vb6, It compiles ok and I
I having trouble in dividing the HTML frames. I have been using the following
I am having trouble with IE7. I have a header, which is an IMG.
I'm having trouble getting a rotary encoder to work properly with AVR micro controllers.
I've been having trouble getting my ASP.NET application to automatically log users into the
I'm having trouble reading a chunked response when using a StreamReader to read the
I'm having trouble with global variables in php. I have a $screen var set
I am having trouble integrating two products, one of which is mine and they

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.