mercredi 13 octobre 2021

Trouble linking a class declaration in the .h file with the implementation in the .cpp file

I cannot figure out why I keep getting the error

"this declaration has no storage class or type specifierC/C++(77) Point"

The error is occurring in point.cpp when I try to define class constructors other than the default. Any advice would be greatly appreciated.

Point.h

enter code here

#ifndef POINT_H

#define POINT_H

#include iostream

namespace hw3{

class Point{

public:

    Point(int Xval, int Yval);
    Point(int Xval);
    Point();
    int getX(int Xval);
    int getY(int Yval); 
    void setX();
    void setY();
     

private:

    int x;
    int y;

};

}

#endif


Point.cpp

enter code here

#include iostream

#include "point.h"

Point::Point(int Xval): x(Xval) {}

Point::Point(int Xval, int Yval): x(Xval), y(Yval) {}

Point::Point(): x(0), y(0) {}

int Point::getX() const {

return x;

}

int Point::getY() const {

return y;

}

void Point::setX(int Xval) {

x = Xval;

}

void Point::setY(int Yval) {

y = Yval; 

}

Aucun commentaire:

Enregistrer un commentaire