if (!current.empty()){ Dependency * temp = current.back(); if (std::find(this->dependents.begin(), this->dependents.end(), temp) == this->dependents.end()){ this->dependents.push_back(temp); //this is the line the compiler does not like } } std::vector dependents; extern std::vector current; //this is the definition from the header file. It also resides in a cpp file without extern