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:


#include <iostream>
using namespace std;

#include "oopy.h"

int main(int argc, char** argv)
	Oopy awesome;
	cout << "Look at this:\n";
	awesome = new Oopy();
	return 0;


#include <iostream>
using namespace std;

include "oopy.h"

Oopy::Oopy() {
	tenFingers= 10;

Oopy::~Oopy() {

oopy::printIt() {
	cout << "You have " << tenFingers << " fingers" << endl;


#ifndef _OOPY_H_
#define _OOPY_H_

class oopy {
		void printIt();
		int tenFingers;


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?

Class awsome is not a pointer you don't use -> .

Oopy.cpp missing something on the include?

Your class is missing a semicolon to finish it.

Did the changes that you suggested, and now I have a whole new set of errors. :(

Is there some simple example OOP stuff I can look at? Everything I google isn't included in an .h file, and if it is theres no .cpp file to go along with it.

Missing ';' symbol..

class oopy
}; // <- this line...

And replace


with this..

// and so on

Ah, turns out I wasn't compiling it properly, I needed to include the .o file.