Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Porting code from C to C++. Among other things changing this:
- struct foo x[count];
- for (unsigned i=0; i<count; i++) {
- x[count].XXX = YYY;
- ....
- function(&x);
- }
- To this:
- std::vector<struct foo> x;
- for (unsigned i=0; i<count; i++) {
- x.emplace_back(YYY, ...);
- function(&x);
- }
- Surprise, surprise, I got unexpected errors when accessing the function's
- argument. Took me about 1h to figure out what's wrong. I think I'm gonna keep
- this as a potential interview question :-)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement