Identical vectors

Hi All,

I've created a code that prompts the user that the vectors in the main function are identical or not. Now I'd like to make this a function where it will prompt the user if the vectors are identical by a true or false statement.


#include <iostream>
#include <vector>

using namespace std;

int main()
{

vector<int> vectorIdentity, Vectoridentity;

vectorIdentity.push_back(1);
vectorIdentity.push_back(2);
vectorIdentity.push_back(3);
vectorIdentity.push_back(4);
vectorIdentity.push_back(5);

Vectoridentity.push_back(1);
Vectoridentity.push_back(2);
Vectoridentity.push_back(3);
Vectoridentity.push_back(4);
Vectoridentity.push_back(5);

if(vectorIdentity == Vectoridentity)
{
cout << "The two vectors are equal.";
}
else
{
cout << "The two vectors are not equal.";
}

return 0;

}
Like so?
1
2
3
4
IsEqual(const vector<int> &vectorIdentity, const vector<int> &Vectoridentity)
{
  return (vectorIdentity == Vectoridentity);
}
Does IsEqual need to be a boolean?
Whoops, I forgot to copy the first part:
1
2
3
4
bool IsEqual(const vector<int> &vectorIdentity, const vector<int> &Vectoridentity)
{
  return (vectorIdentity == Vectoridentity);
}
Excellent. Thank you.
Topic archived. No new replies allowed.