Header file problem

So I was given a header file from my professor, we were instructed to create the functions in the class in another .cpp file then create another .cpp file to do test cases. Well I'm having an issue when I try to test one of the functions. I keep getting the error "not declared in this scope" (my display() function).
Please take a look and tell me where I'm making error, as im going crazy trying to debug.

Vector.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
  #ifndef VECTOR_H_DMW 
#define VECTOR_H_DMW
#include <iostream>
#include <cmath>  //if needed

using namespace std;

class Vector
{
  double _x;
  double _y;
  double _z;

public:
  Vector();
  Vector(double X, double Y, double Z = 0.0);
  void display() const; // <_x, _y, _z>
  void add(const Vector&);
  void sub(const Vector&);
  void mult(const double&);
  void div(const double&);
  void normalize();
  double length()const;
};

#endif  


Vector.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "Vector.h"

Vector::Vector()
{
  _x = 0.0;
  _y = 0.0;
  _z = 0.0;
}

Vector::Vector(double X, double Y, double Z)
{
  _x = X;
  _y = Y;
  _z = Z;
}

void Vector::display( ) const
{
  cout<<"<"<<_x<<","<<_y<<","<<_z<< ">";
}


Vectormain.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include "Vector.h"


int main()
{
  Vector v1;
  v1 = Vector(1.0,2.0,3.0);
  display(v1);
  //Vector::display(v1)
  //Vector::display()
  //display()
  return 0;
} 


Thanks in advance!
v1.display();

One calls the member functions via an object

Your version supplies an argument; there is no such function. Even without the argument, there is still no such function.
Last edited on
That makes total sense! Lmao Tysm
Topic archived. No new replies allowed.