I started C++ programming few weaks ago and i have a question about defining the file of a class in a separate file. This is my code.
main.cpp
#include <iostream>
#include "Maths.h"
int main() {
Maths m;
int s = m.sum(1,2);
std::cout << s << std::endl;
return 0;
}
Maths.h
#ifndef Maths_H
#define Maths_H
class Maths
{
public:
int sum(int a, int b);
};
#endif
Maths.cpp
#include <iostream>
#include "Maths.h"
int Maths::sum(int a, int b)
{
return a + b;
}
Why is it that you can't #define
the same name as your class name. For example in my script Maths?
https://repl.it/repls/UnwillingFreeHeterodontosaurus