Hi everyone!
I'm totally new at C++ but quite good at Java. I know the syntax basics and that kind of stuff in C++ but when it comes to using .h files in my .ccp programs I'm totally on bare bottom.
I use Dev-C++ 4.9.9.2 to compile my C++ programming.
Please take a look at my Shapes.h file:

class Shapes
{
public:
    Shapes(char shape, int x, int y, int width, int height);
};

And at my Shapes.cpp:

#include <iostream>
#include "Shapes.h"
using namespace std;

Shapes::Shapes(char shape, int x, int y, int width, int height);
{
    cout << "You created a: " << shape " shape. At X: " << x " At Y: " << y " Width: " << width " Height: " << height << endl;
}

int main()
{
    new Shapes('r', 10, 10, 10, 10);
	
	system("pause");
	return 0;
}

And this is the code the compiler generated:

2 C:\Documents and Settings\Benjamin Dahse\Shapes.cpp In file included from C:\Documents and Settings\Benjamin Dahse\Shapes.cpp 
5:3 C:\Documents and Settings\Benjamin Dahse\Shapes.h [Warning] no newline at end of file 
5 C:\Documents and Settings\Benjamin Dahse\Shapes.cpp declaration of `Shapes::Shapes(char, int, int, int, int)' outside of class is not definition 
6 C:\Documents and Settings\Benjamin Dahse\Shapes.cpp expected unqualified-id before '{' token 
6 C:\Documents and Settings\Benjamin Dahse\Shapes.cpp expected `,' or `;' before '{' token 
16:2 C:\Documents and Settings\Benjamin Dahse\Shapes.cpp [Warning] no newline at end of file

Please help me and remember that I'm new to C++ so I might be hard to explain stuff too.. I don't know.. If that's the case compare it to Java and I'll probaly get it :P

a good way to stay orginixed is to split your classes up into 2 files. a .h file that will for the deleeration of the class and a .cpp file that will hold the definition of the class and then you would include them into your main.cpp file such as:

foo.h

class foo
{
 foo(int)
// ...
};

foo.cpp

#include foo.h

foo::foo(int foo)
{
// ...
}

main.cpp

#include "foo.h"

int main()
{
foo foobar(5);
//...
}

btw the new keyword is use to get a pointer to a new object if you just want to make a shape object but not a pointer the just use Shapes square("square", 0, 0, 10, 10);

a good way to stay orginixed is to split your classes up into 2 files. a .h file that will for the deleeration of the class and a .cpp file that will hold the definition of the class and then you would include them into your main.cpp file such as:

foo.h

class foo
{
 foo(int)
// ...
};

foo.cpp

#include foo.h

foo::foo(int foo)
{
// ...
}

main.cpp

#include "foo.h"

int main()
{
foo foobar(5);
//...
}

btw the new keyword is use to get a pointer to a new object if you just want to make a shape object but not a pointer the just use Shapes square("square", 0, 0, 10, 10);

Well thank you for the well explained reply!

Your porblem was :

Shapes::Shapes(char shape, int x, int y, int width, int height); <--THIS SEMICOLON
{
    cout << "You created a: " << shape " shape. At X: " << x " At Y: " << y " Width: " << width " Height: " << height << endl;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.