I still don't get all that, mentioned in the thread title.
Right now I'm using the Code::Blocks IDE, and it's getting me really confused about headers, implementations, and #include.
When I add a class in CodeBlocks, it puts the header file in a folder called include, and puts the cpp file in a folder called src. My Main.cpp file is in the same directory as these folders.
Now without changing anything, I tried to include the header file. Auto complete tells me something like this:
When I compile, however, a lot of errors are thrown:
D:\Dev\C++\Test1\Test\src\Foo.cpp|1|error: Foo.h: No such file or directory|
D:\Dev\C++\Test1\Test\src\Foo.cpp|3|error: 'Foo' has not been declared|
D:\Dev\C++\Test1\Test\src\Foo.cpp|3|error: ISO C++ forbids declaration of 'Foo' with no type|
D:\Dev\C++\Test1\Test\src\Foo.cpp||In function 'int Foo()':|
D:\Dev\C++\Test1\Test\src\Foo.cpp|6|warning: no return statement in function returning non-void|
D:\Dev\C++\Test1\Test\src\Foo.cpp|8|error: expected constructor, destructor, or type conversion before '::' token|
||=== Build finished: 4 errors, 1 warnings ===|
Code Blocks generated the two files to be like this, and I have not modified them:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
//Foo.cpp
#include "Foo.h"
Foo::Foo()
{
//ctor
}
Foo::~Foo()
{
//dtor
}
//Foo.h
#ifndef FOO_H
#define FOO_H
class Foo
{
public:
Foo();
virtual ~Foo();
protected:
private:
};
#endif // FOO_H
|
I was hoping someone on this forum could explain to me what is the common method of making classes and folder structures.