News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Problem With 2d Vector in Latest Release CB 10.05

Started by nyislander, December 27, 2010, 10:42:51 PM

Previous topic - Next topic

nyislander

I installed the latest version of CB with mingw and when I try to debug the attached code I get the following error message which points at the declaration of the 2d temp vector: "no matching function for call to 'std::vector<std::vector<int ..." .  If I use a 1d vector it works.  Any suggestions?

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>

using namespace std;


int main()
{ // main

int j = 0, h = 0;
vector< vector< int > > temp ( 5, 0 );

        for (h = 0; h < 5; ++h){for (j = 0; j < 5; ++j){temp[h].push_back(j); cout << setw(2) << temp[h][j];}}
        system("PAUSE");

} // end main

oBFusCATed

1. Try the debuggers branch nightly (probably won't help)
2. Paste the debugger's debug log. This log is shown by Settings -> Compiler and debugger -> Debugger -> Display debugger's log.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

nyislander

#1: didn't try.
#2:

-------------- Build: Debug in junk ---------------

Compiling: main.cpp
In file included from c:\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/vector:65,
                 from C:\Cpp\junk\main.cpp:4:
c:\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/stl_vector.h: In member function 'void std::vector<_Tp, _Alloc>::_M_initialize_dispatch(_Integer, _Integer, std::__true_type) [with _Integer = int, _Tp = std::vector<int, std::allocator<int> >, _Alloc = std::allocator<std::vector<int, std::allocator<int> > >]':
c:\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/stl_vector.h:303:   instantiated from 'std::vector<_Tp, _Alloc>::vector(_InputIterator, _InputIterator, const _Alloc&) [with _InputIterator = int, _Tp = std::vector<int, std::allocator<int> >, _Alloc = std::allocator<std::vector<int, std::allocator<int> > >]'
C:\Cpp\junk\main.cpp:17:   instantiated from here
c:\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/stl_vector.h:991: error: no matching function for call to 'std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >::_M_fill_initialize(size_t, int&)'
c:\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/stl_vector.h:1033: note: candidates are: void std::vector<_Tp, _Alloc>::_M_fill_initialize(size_t, const _Tp&) [with _Tp = std::vector<int, std::allocator<int> >, _Alloc = std::allocator<std::vector<int, std::allocator<int> > >]
Process terminated with status 1 (0 minutes, 0 seconds)
1 errors, 0 warnings


danselmi

This is not a CB related problem. Check the initialization of temp. Try this one: vector< vector< int > > temp(5);
spell checker plugin: [url="http://developer.berlios.de/projects/spellchecker/"]http://developer.berlios.de/projects/spellchecker/[/url]
nassi shneiderman plugin: [url="http://developer.berlios.de/projects/nassiplugin"]http://developer.berlios.de/projects/nassiplugin[/url]

Jenna

Quote from: danselmi on December 27, 2010, 11:52:46 PM
This is not a CB related problem. Check the initialization of temp. Try this one: vector< vector< int > > temp(5);

As danselmi wrote:
not related to C::B in any way and therfore violating our forum rules.
C::B is not a compiler "just" an IDE, that works with many compilers.

Topic locked !!