Hi I am getting this error when running a very similar code like the below, it is made for illustration only.
thanks *************************************** **************** error **************** (gdb) n terminate called after throwing an instance of 'std::bad_alloc' what(): St9bad_alloc Program received signal SIGABRT, Aborted. 0xb7cd17c7 in raise () from /lib/tls/libc.so.6 (gdb) bt #0 0xb7cfa7c7 in raise () from /lib/tls/libc.so.6 #1 0xb7cfc06b in abort () from /lib/tls/libc.so.6 #2 0xb7eef644 in __gnu_cxx::__verbose_terminate_handler () from /usr/lib/libstdc++.so.6 #3 0xb7eed035 in std::set_unexpected () from /usr/lib/libstdc++.so.6 #4 0xb7eed072 in std::terminate () from /usr/lib/libstdc++.so.6 #5 0xb7eed1aa in __cxa_throw () from /usr/lib/libstdc++.so.6 #6 0xb7eed5eb in operator new () from /usr/lib/libstdc++.so.6 #7 0x0804d28b in __gnu_cxx::new_allocator<fxpair>::allocate ( this=0xbff45c7c, __n=27531841) at /usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/ext/new_allocator.h:88 #8 0x0804d2b0 in std::_Vector_base<fxpair, std::allocator<fxpair> >::_M_allocate (this=0xbff45c7c, __n=27531841) at /usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/bits/stl_vector.h:117 #9 0x0805405a in std::vector<fxpair, std::allocator<fxpair> >::_M_insert_aux (this=0xbff45c7c, __position={_M_current = 0x805d1ac}, [EMAIL PROTECTED]) at /usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/bits/vector.tcc:275 #10 0x08054428 in std::vector<fxpair, std::allocator<fxpair> >::push_back ( this=0xbff45c7c, [EMAIL PROTECTED]) at /usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/bits/stl_vector.h:610 #11 0x08052cbd in main () at main.cpp:85 *************************************** **************** code ***************** #include <string> #include <vector> #include <iostream> using namespace std; class acc_holder { string name; double a, b, c, d, e, f, g; double max_weekly_withdraw; double daily_withdraw; int h; public: acc_holder(string nam, double d_withdraw) : name(nam), daily_withdraw(d_withdraw), a(0), b(0), c(0), d(0), e(0), f(0), g(0) {} void update_weekly_figurs() { max_weekly_withdraw += daily_withdraw; cout << name << ": " << max_weekly_withdraw << '\t'; } }; int main(){ acc_holder jack("jack", 1.1); acc_holder mary("mary", 1.2); acc_holder sam("sam", 1.3); acc_holder job("job", 1.4); vector<acc_holder> fund_participanets; fund_participanets.push_back(jack); fund_participanets.push_back(mary); fund_participanets.push_back(sam); fund_participanets.push_back(job); for( unsigned i = 0; i<=3; i++){ for(unsigned j = 0; j<=fund_participanets.size()-1; j++){ fund_participanets[j].update_weekly_figurs(); } cout << '\n'; } } _______________________________________________ help-gplusplus mailing list help-gplusplus@gnu.org http://lists.gnu.org/mailman/listinfo/help-gplusplus