I have a vector delared in a header file a.h
:
// in a.h
class A {
public:
...
std::vector<glm::mat4> transforms;
}
I tried to push_back()
an object into it in my a.cpp
file:
// in a.cpp
glm::mat4 transform;
transforms.push_back(transform); // errors here
but I'm getting these errors:
no instance of overloaded function "std::vector<_Ty, _Alloc>::push_back [with _Ty=glm::mat4, _Alloc=std::allocator]" matches the argument list and object (the object has type qualifiers that prevent a match)
and
'std::vector>::push_back': 2 overloads have no legal conversion for 'this' pointer
If I try to declare the vector directly inside the a.cpp
file then it works:
// in a.cpp
std::vector<glm::mat4> foo;
foo.push_back(transform); // this works
What is going on? What did I do wrong when I declared the vector in the header file?