C++ help please (10 points)?

a sexually transmitted disease::vector::size_type liveCount(std::vector v)
a sexually transmitted disease::vector::size_type count = 0;
for( a sexually transmitted disease::vector::size_type post = 0; post! = v.size(); i++ )
if( isLive( vi ) )
++count;
returning count;

How do you pass this vector simply by constant research.

And how do i use iterators besides indexing.

Any help appreciated

// The actual parameter now is often a const reference
a sexually transmitted disease::vector::size_type liveCount(const a sexually transmitted disease::vector &v)
a sexually transmitted disease::vector::size_type count = 0;
// for( a sexually transmitted disease::vector::size_type post = 0; post! = v.size(); i++ )
// with regard to loop making use of iterator
with regard to (std::vector::iterator the_iterator = v.begin(); the_iterator! = v.end(); the_iterator++)
if( isLive( the_iterator ) )
++count;

returning count;

of course you can pass these individuals normally (that is usually pass these people by value).but once you pass physical objects by value what are the results is that the new subject is created then the concept you complete is copied for the new concept.this, with regard to standard styles (char, int, drift etc) is usually ok, because common types are usually small in space (char is definitely one byte, simple is COUPLE OF, int is actually 2 or perhaps 4, long is FOUR etc…).a vector however is not that little.Try doing this:

1
2
3
4
5
6
7
8
9
10
11
12

#include
#include
employing namespace std;

int main()

vector v;
cout << sizeof(v) << endl;

system(“pause”);
returning 0;

Leave a Reply