Problem with Header files

Currently, i'm running Code::Blocks for my compiler. Whenever I create a new class, a .cpp and a .h are created, along with the data from the main file.

Main file:

#include "ClassesInSeperateFiles.h"
#include <iostream>
using namespace std;
int main()
{
ClassesInSeperateFiles Object;

New .cpp file:

#include <iostream>
#include "ClassesInSeperateFiles.h"
using namespace std;
ClassesInSeperateFiles::ClassesInSeperateFiles()
{
cout << "I would like to be a ballerina." << endl;
}

New .h File:

#ifndef CLASSESINSEPERATEFILES_H
#define CLASSESINSEPERATEFILES_H


class ClassesInSeperateFiles
{
public:
ClassesInSeperateFiles();
};

#endif

Help, please.
What exactly is the problem?

Also; use code tags, much easier to keep track of what is going on.
Whenever I create a new class, a .cpp and a .h are created, along with the data from the main file.


Code::Blocks is probably trying to help in creating a .cpp and .h file for each class you define, because it is a common practice to have header and .cpp files where one or more classes(and other variables, functions etc) used in a program are declared and defined. This is only a common practice used for organizational purposes though, and a single .h (or .cpp) file could contain all of the code referred to.

I don't use Code::Blocks so I didn't know about this. Anyway, if you create empty files as required, and then write your classes' code in the code editor, I don't think you'll get any attempts from Code::Blocks to organize your project's code files.
I'd suggest using a .hpp file instead of a .h, just be explicit regarding C and C++ code.
Thanks, added code tags and used a .hpp extention, and it worked.
Topic archived. No new replies allowed.