User forums > Using Code::Blocks
Question about making a class
(1/1)
c_weed:
Hello everyone, :D
It was my understanding that the main file (main.cpp) includes the header file (MyClass.h) which includes the implementation file (MyClass.cpp)
main.cpp-->MyClass.h-->MyClass.cpp
So how come when I select new, class Code::Blocks gave me this
--- Code: ---#include LinkedList.h
#include "LinkedList.h"
LinkedList::LinkedList()
{
//constructor
}
LinkedList::~LinkedList()
{
//dtor
}
--- End code ---
where the header file is included in the implementation file?
Jenna:
Because your
--- Quote from: c_weed on October 20, 2010, 12:06:47 am ---[..] understanding that the main file (main.cpp) includes the header file (MyClass.h) which includes the implementation file (MyClass.cpp)
main.cpp-->MyClass.h-->MyClass.cpp
--- End quote ---
is wrong.
c_weed:
Got it. :)
c_weed:
I thought I got it but didn't after all. I thought you were saying that the implementation file should include its header file, but I thought the main file included the implementation file.
main.cpp-->class.cpp-->class.h
how come this is wrong?
how does including the header from the main file work because doesn't the implementation (class.cpp) not get included?
MortenMacFly:
--- Quote from: c_weed on October 26, 2010, 01:11:10 am ---how does including the header from the main file work because doesn't the implementation (class.cpp) not get included?
--- End quote ---
Sorry, but this is no longer within the scope of our forum and violates the forum rules therefore. Please grab yourself a C++ beginners book and read about the basics. Basically sections about how a compiler works, and what a linker does.
Topic locked.
Navigation
[0] Message Index
Go to full version