0

I'm fairly new to programming and really don't understand what is going on when I get the error "undefined reference to 'Rectangle::Rectangle(int, int)'".

This is the program that I am running and will not compile

#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>

using namespace std;



class Rectangle
{
public:
  Rectangle( int, int );

  void print();

  void setWidth( int );
  void setHeight( int );

  int getWidth();
  int getHeight();

  int calcArea();

  bool isSquare();

private:
  int width, height; 
};




int main()
{
int testNum =1;

cout << "Test " << testNum++ << ": the constructor and print method" << endl;

//Create two objects
Rectangle rec1(0, 0);
Rectangle rec2(12, 5);

//Display the two objects by calling the print method.

cout << endl << "Rectangle 1:" << endl;
rec1.print();

cout << endl << "Rectangle 2:" << endl;
rec2.print();

return 0;
}

I've been scratching my head for a while over this. The error originates when I try to create the objects rec1 and rec2. I don't currently have any of the functions referenced in the class programmed, could that be the reason why I am getting an error? Any help would be appreciated.

0 Answers0