So I have 2 files linked: Fraction.h and main.cpp
Fraction.h contains function definitions and declarations
main.cpp is where int main is:
Code:
Class Fraction
int a;
public:
Fraction(int a, int b) // initialized constructor
{
a= 0;
}
int get ()
{
return (a+1);
}
Code:
#include "Fraction.h"
int main ()
{
int a,b;
cin >> a>>b;
Fraction test (a,b);
cout << test. get() ;
}
error: undefined reference to Fraction :: Fraction (int, int)
In the header file, i declared int a and set it to 0. When i call the object test.get() in main, the result should be 1. Instead it's giving me the error: I think its saying somehow my constructor is undefined? But i dont see where. It's such a simple program.