just a novice learning C++. It's a great language with a steep learning curve and I am climbing that mountain.
Currently, I want to compare two vector, the first vector already has predefined elements, while the other vector's elements are inputted on the go (i.e. "cin in a while loop"). The output of the vector comparison should be a string, "bleep", whenever similar strings are matched between the two sorted vectors. Else, the vector with the inputted words will print out it's elements.
Side Note: The code is a bit religious (I decided to use a standard text that I know - the Bible). So I am not trying to condemn anyone I just needed a standard text we all have access to. Also, I have searched online and some suggestions for comparing vectors required that I used set_difference, set_intersection etc. I have checked them out, but I realised that it will take a novice like me more time to understand the interator syntax. So that is why I am here.
So please I need your help because the code keeps giving this error from the implementation file:
I know. I wish i could solve the error (Error's are actually the topic for the next chapter in the book I am reading)
So enough small talk here is the code I have been working on. Any pointers will be appreciated. Thanks in advance:)
#include "stdafx.h"
#include "Std_lib_facilities.h"
int main()
{
// Introduction
cout << "This program will compare the your input to already predefined works which are found in Galatians 5:19-24.";
// Vectors of disliked by God in Galatians 5:19-24. These are the works of the flesh. And I copied them from the Bible.
// Side comment:I know we are all sinners- I am not judging anyone. I myself am working on some with the help of the Holy Spirit and my spirit is getting stronger everyday.
vector <string> disliked; disliked[0]= "hatred"; disliked[1] = "envy"; disliked[2] = "adultery"; disliked[3] = "fornication"; disliked[4] = "anger"; disliked[5] = "malice";
disliked[6] = "gluttony"; disliked[7] = "lying"; disliked[8] = "stealing"; disliked[9] = "greed"; disliked[10] = "uncleanliness"; disliked[11] = "lewdness"; disliked[12] = "idolatry";
disliked[13] = "sorcery"; disliked[14] = "contentions"; disliked[15] = "jealousy"; disliked[16] = "selfish ambition"; disliked[17] = "dissensions"; disliked[18] = "heresies";
disliked[19] = "murder"; disliked[20] = "drunkeness"; disliked[21] = "revelries";
// Sorted the vectors so that they could be compared with what are liked.
sort(disliked.begin(), disliked.end());
cout << "Please enter the fruits of the Holy Spirit in Galatians 5:22-23, while purposely adding some of the works of the flesh which are found in Galatians 5:19-24: \n" <<
"Also inset a Ctrl+Z and click enter when you have finished inserting the works"<< endl;
string first_input; // String for the input of the likes. Please, you are to purposely insert some words that are not listed in Galatians 5:22-23. Rather include some from Galatians 5:19-24
vector <string> liked; // Vector of liked qualities
while (cin >> first_input) // cin iostream is used to insert the whitespace separated strings into first_input
liked.push_back(first_input); // push_back inserts the strings from first_input into the vector liked
sort(liked.begin(), liked.end()); // the vector liked is sorted.
for (int i = 0; i < liked.size(); ++i) // Using the loop for the comparison of the sorted vectors in the next if statment
if (disliked == liked) // if strings are similar give a bleep!
cout << "Bleep!" << endl;
else
cout << liked[i]; // if strings are not similar cout the list of liked qualities.
}