Here is my code:
#include <iostream>
#include <vector>
#include <string>
using namespace std;
template<int N>
class Arguments
{
protected:
string arguments[N];
public:
Arguments(const string(&arg)[N]) : arguments{ arg } {}
string operator[](const int &i) const { return arguments[i]; }
};
int main()
{
string arr[3] = { "arg1", "arg2", "arg3" };
Arguments<3> args(arr);
cout << args[2];
return 0;
}
This is the error i get:
Severity Code Description Project File Line Suppression State
Error C2440 'initializing': cannot convert from 'const std::string [3]' to 'std::string'
coursework_draft C:\dev\coursework_draft\coursework_draft\coursework_draft.cpp 13
What do i need to change?
std::arraywhich can be copied normally.