So I decided to start learning c++ I wanted to find out how to use classes in it. I thought I had set it up correctly (From looking at tutorials) but it gives me the following error..
C:\Dev-Cpp\main.cpp `Math' does not name a type
I am new to c++ and the Dev-C++ Compiler so I haven't figured out the errors yet. HEre is my code..
Main class:
#include <cstdlib>
#include <iostream>
using namespace std;
//variables
int integer;
Math math;
int main()
{
math = new Math();
integer = math.add(5,2);
cout << integer << endl;
system("PAUSE");
return EXIT_SUCCESS;
}
Here is my Math.cpp class:
#include <cstdlib>
#include <iostream>
#include "Math.h"
using namespace std;
public class Math {
public Math::Math() {
}
public int Math::add(int one, int two) {
return (one+two);
}
}
And the Math header file:
public class Math {
public:
public Math();
public int add(int one, int two) {one=0; two=0};
};
Any help would be appreciated, I have been trying to work this out for awhile now.