I have a file called MyVector.cpp:
#include "MyVector.h"
MyVector::MyVector(double x ,double y ,double z){
this->v[0] = x;
this->v[1] = y;
this->v[2] = z;
this->v[3] = 1.0;
}
and header with the name MyVector.h:
#ifndef MYVECTOR_H
#define MYVECTOR_H
#include <iostream>
class MyVector{
public:
double v[4];
MyVector(double x ,double y ,double z);
};
#endif
In the main file I try to use the class MyVector:
#include <iostream>
#include "MyVector.h"
int main(){
MyVector v(1.0 ,2.0 ,3.0);
std::cout << v.v[0] << "\n";
std::cout << v.v[1] << "\n";
std::cout << v.v[2] << "\n";
std::cout << v.v[3] << "\n";
return 0;
}
But all I get is an error saying the refrence to the constructor (MyVector) is undefined.
undefined reference to
MyVector::MyVector(double, double, double)`
I tried to change the names of the class but it didnt work