News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

Question about making a class

Started by c_weed, October 20, 2010, 12:06:47 AM

Previous topic - Next topic

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
#include LinkedList.h

#include "LinkedList.h"

LinkedList::LinkedList()
{
    //constructor
   
}

LinkedList::~LinkedList()
{
    //dtor
}


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
is wrong.

c_weed


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?
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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]