I get the no default constructor exists for class "vector" Error
main.cpp
#include <iostream>
#include <string>
#include "myVector.h"
using namespace std;
int main()
{
vector<int> myvecA;
cout << "Vector A size: " << myvecA.size() << endl;
system("Pause");
return 0;
}
myVector.h
#include <iostream>
using namespace std;
template <class V>
class vector{
public:
vector(V x) {
bool(x = 0)
sizearr = 0;
if (x != 0)
return x;
sizearr = x;
}
V size();
private:
V sizearr;
};
template <class V>
V vector<V>::size() {
return sizearr;
}
I don't know how to make it so that if
vector<int> myvecA;
doesn't contain a construct that it will set the construct to 0 so i can return size as 0.
I apologize if my question is not very clear. I'm just look for help so I can learn.I'm not very good at c++.