std::vector Problem

Started by
4 comments, last by carb 20 years, 5 months ago
For some reason, when I create three vectors of type std::vector ... Only the first work. Trying push_back on the second and third declared vectors turns into a segmentation fault. The actual declaration is: std::vector list1, list2, list3; list1.push_back(5) // is fine list2.push_back(6) // seg fault same if i try pushing list2 before list1, it seg faults on list2 ... What''s the dilio? - Ben
- Ben
Advertisement
I just tried it, and it works fine. no faults or anything.

maybe your OS has mangled memory up together that dont belong to eachother. Maybe try restarting your computer? Alternatively, reinstall format/reinstall everything.

:::: [ Triple Buffer ] ::::
[size=2]aliak.net
not sure if you need to reformat and stuff, that sounds kinda harsh. But could you repost your code? Preferably in [ source ] tags? Since we can''t see what type you''re creating your vector with. If it''s some built in type (like int, float, etc) then there should be no problem with your code. If it''s some class that you did then mabye somethings wrong with your constructor?

}-- Programmer/Gamer/Dreamer --{
[ ThumbView: Adds thumbnail support for DDS, PCX, TGA and 16 other imagetypes for Windows XP Explorer. ] [ Chocolate peanuts: Brazilian recipe for home made chocolate covered peanuts. Pure coding pleasure. ]
He''s using unsigned ints (click ''edit'').

I see no reason why it should segfault.

[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
quote:Original post by Seriema
not sure if you need to reformat and stuff, that sounds kinda harsh. But could you repost your code? Preferably in [ source ] tags? Since we can''t see what type you''re creating your vector with. If it''s some built in type (like int, float, etc) then there should be no problem with your code. If it''s some class that you did then mabye somethings wrong with your constructor?

}-- Programmer/Gamer/Dreamer --{


It looks like he''s using ints. But you''re right, if its a custom type then maybe that is where the problem is...

carb: either use source tags especially for templates or type the actual html codes ie: "& g t ;" for the greater then sign (without spaces) or "& l t ;" for less then

vector<int>

:::: [ Triple Buffer ] ::::
[size=2]aliak.net
quote:Original post by Fruny
He''s using unsigned ints (click ''edit'').

I see no reason why it should segfault.

[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]



hmm. indeed. BTW Fruny, you know that whoever tries to search for answers to boost questions in these forums gets all the posts you ever made on gamedev with that sig of yours. Its impossible really. Ive recentrly been a victim :/

:::: [ Triple Buffer ] ::::
[size=2]aliak.net

This topic is closed to new replies.

Advertisement