I'm just diving back into C++ after a while of being away. I've created a simple project. But its giving me these stupid errors when I've been trying to do some OOP:
main.cpp
#include <iostream>
using namespace std;
#include "oopy.h"
int main(int argc, char** argv)
{
Oopy awesome;
cout << "Look at this:\n";
awesome = new Oopy();
awesome->printIt();
return 0;
}
oopy.cpp
#include <iostream>
using namespace std;
include "oopy.h"
Oopy::Oopy() {
tenFingers= 10;
}
Oopy::~Oopy() {
}
oopy::printIt() {
cout << "You have " << tenFingers << " fingers" << endl;
}
oopy.h
#ifndef _OOPY_H_
#define _OOPY_H_
class oopy {
public:
oopy();
~oopy();
void printIt();
private:
int tenFingers;
}
#endif
Pretty simple stuff, right? Well when I try to compile it with G++, I get the following error:
main.cpp:6: error: new types may not be defined in a return type
main.cpp:6: note: (perhaps a semicolon is missing after the definition of ‘oopy’)
main.cpp:6: error: two or more data types in declaration of ‘main’
I can't figure it out. Any help?