"Car - Debug uses an invalid compiler. Probably the toolchain path within the compiler options is not setup correctly?! Skipping... Nothing to be done." |
I haven't used Code::Blocks before but this sounds like an IDE setup issue. Probably the compiler (e.g. MinGW) is not attached to your project. Sorry I can't help you any more than that.
1 2 3 4 5 6
|
#ifndef CARCLASS_H_INCLUDED //I called my Header file "CarClass.h" and these first three
#define CARCLASS_H_INCLUDED //lines appeared automatically
#endif // CARCLASS_H_INCLUDED
|
If you want to know what this is, it's called an
include guard. Essentially, it prevents a .h file from being
#include
d multiple times in the same translation unit (otherwise it would generate a linker error). However, with the way you have it, it just prevents a bunch of white space from being included multiple times. What you should do is put the
#endif // CARCLASS_H_INCLUDED
at the
bottom of the .h file. Another way to prevent multiple
#include
s is to simply add
#pragma once
at the top of your .h (though this isn't fully supported and you may run into troubles with this, especially on older compilers).
Another thing I noticed that will give you problems is in "CarClass.h", you're not placing
std::
in front of
cout
and
endl
. You need to do this because your .h is not
using namespace std;
, only main is. Either put
using namespace std;
in "CarClass.h" or put it above the
#include "CarClass.h"
statement in main.cpp. Although I don't think putting it within the .h file is good style because that would make any file that includes CarClass.h also use the standard namespace (maybe not what that file wanted!). It may be better just to use
std::
within the .h, but really it's up to you.