Im trying to grasp the concept of Classes, Structure's and Object Orientated programming and im having a lot of trouble, i have this very simple bit of code that im getting an error on
#include <cstdlib>
#include <iostream>
using namespace std;
class Rational{
public:
Rational::Rational(double n,double d){
num = n;
denom = d;
}
Only use the scope function when defining member functions outside of the class, e.g.
1 2 3 4 5 6 7 8 9
class MyClass{
public:
MyClass();
void funct1(); //Provide prototypes to let compiler know there is a member function
void funct2();
};
MyClass::MyClass(){/*...*/}
void MyClass::funct1(){/*...*/}
void MyClass::funct2(){/*...*/}
Or just define the functions directly inside the class, though the prior example is more preferable.
1 2 3 4 5 6
class MyClass{
public:
MyClass(){/*...*/}
void funct1(){/*...*/}
void funct2(){/*...*/}
};
But im still getting errors saying Rat1 and Rat2 are not classes and that print is undeclared but arent Rat1 and Rat2 suppose to be Objects not classes?