how to pass a vector to a function
how to pass a vector to a function
perhaps?Code:int somefunction(const vector<int> &vec);
Exactly how you do it depends on what you actually want to happen - the const in the above says "somefunction promises not to to change vector".
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
Instead of posting every question you have, you should actually go read some tutorials.
After all, there is a reason why professors get paid to give lectures.
hi MacGyver , if u have problem answering my questions simply ignore it, but dont make unneceesary comments!
thanks matsp, i will try it
I think MacGyvers comment was more for your benefit - you will at some point or another need to find a process or acquiring information in other ways than asking each individual detail on a forum.
Most people attend a forum just BECAUSE they like answering questions. But a question like yours is both simple and difficult, because it so much depends on "how you mean", and writing out ALL of the necessary information would be difficult - and it has already been done in books and tutorials.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
I'm making a very necessary comment. If you don't like it, just because you're particularly lazy and don't feel like reading a tutorial, I really don't care.
Being a programmer is more than just typing text and making the computer do something. Brain dead users can type in text and make the computer do something. Real programmers need to be able to come up with solutions on the fly to various problems that they may have never seen before. In order to achieve this, you have to learn how to properly learn. Asking someone to teach you something is usually not something you can do. If you're a professional programmer, then you can't ask us every little detail for something you're working on. Another thing to consider is that there is information all over the Internet on how to learn how to program. This isn't the Dark Ages. You can find the information you need. The test of a diligent worker is to see how they find and utilize this knowledge.
If you learn how to learn, you are closer on your way to being a good programmer. Part of this is learning how to glean information from tutorials and books. There is nothing wrong with asking people when you get stuck. No sense in reinventing the wheel everytime, however, if you're not going to think for yourself, there's no reason for us to help you. After all, why should anyone help you if you won't help yourself?
Show us you've made an effort.
Edit: matsp is exactly right. You need to be able to research information yourself because it's only going to get harder until you finally master the language. Little details of syntax is what you need to personally work on. If you've been spoon-fed everything, how are you going to be able to learn the more advanced concepts? I don't know how many people you will find on forums to teach you everything in a lecture-style approach.
Last edited by MacGyver; 12-20-2007 at 08:38 PM.
sorry MacGyver, i will try to learn myself before asking any question on this forum...
there are a number of wonderful books listed at near the start of this list - try reading a few and following the examples. Try googling for Thinking in C Plus Plus - wonderful book and free online