Basically what the question says: I'm unable to initialize a vector of any kind in C++;
Here is my code:
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
//The error occurs under the word "lines" in the following line
vector<string> lines{"Hello", "there", "General", "Kenobi", "you",
"are", "a", "bold", "one"};
}
The error is shown by a red squiggly line under the word "lines" in the program. and here is my error:
no instance of constructor "std::__1::vector<_Tp, _Allocator>::vector [with _Tp=std::__1::string, _Allocator=std::__1::allocator<std::__1::string>]" matches the argument list -- argument types are: (const char [6], const char [6], const char [8], const char [7], const char [4], const char [4], const char [2], const char [5], const char [4])C/C++(289)
std::__1::vector<std::__1::string> lines
I looked up this problem extensively and couldn't find a single useful source. One resource I came across advised to use another header file (std_lib_facilities.h) and this didn't work even when I added it. I also tried it with prefixing everything with std:: and not using std as the namespace, but this also didn't do anything.
As a last ditch, I copied working examples of code from online and tried to run them, and I got the same, reproducible error each time, even when creating vectors of ints or chars.
I'm sure I'm missing something simple, but I have been unable to figure it out. If you know, please help me out.
As always, if you answer or attempt to answer this question, thank you for your time.
EDIT: The question that this was suggested was a duplicate of is not. The solution to this problem involved editing my tasks.json file and the other answer had essentially nothing to do with my issue.