I am creating a simple class
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
class MyClass {
int p;
public:
MyClass( int q ) { p = q; }
};
but when I try to create this vector
vector<int, MyClass> vec1(1);
my code breaks and throws this exception
vector<int,MyClass> vec1(1);
In instantiation of ‘struct std::_Vector_base<int, MyClass>’:
/usr/include/c++/9/bits/stl_vector.h:386:11: required from ‘class std::vector<int, MyClass>’
vector_class.cpp:19:26: required from here
/usr/include/c++/9/bits/stl_vector.h:84:21: error: no type named ‘value_type’ in ‘class MyClass’
84 | rebind<_Tp>::other _Tp_alloc_type;
Can I resolve this means can I use int type with user defined types in vector like this vector<int,MyClass>