i wonder it, because i hate c++ header files. if c# compiler has a way of getting rid of them, why cant c++ do?
here some similar info but i am not satisfied.
http://stackoverflow.com/questions/1305947/why-does-c-need-a-separate-header-file

majestic0110 commented: Good question! +5

Recommended Answers

All 13 Replies

No i posted it to here to have Scott involved in the conversation.
Today he is in good mood. And also i really wonder how c# deals without having header files, if that can be done, why c++ has them, of course it cant be for bothering the programmer.

commented: i'm always in a good mood, and this proves it! for today anyway +17

Some 20 years ago I programmed in this language
It had the concept of a DEFINITION MODULE(= +-header file) and IMPLEMENTATION MODULE. You could design all your definitions and then let a team of programmers fill in the implementations. It would complile even if not all implementations were filled in.
So you could say FROM Circle IMPORT Draw; to use the Draw procedure, while other procedures like CalculateArea are perhaps not yet implemented!
In C (I believe also in C++) when you include a header file, all of the implementation would be loaded in your program, even if you don't need it. Possible that a smart C or C++ compiler will prune out the code that is not needed afterwards, I dont know.
C# is a modern language and VS is a nice environment to develop in, so who needs headers in the 21th century?

commented: interesting! +5

So you think c# is better than c++? if Narue were alive, she would prove you wrong as a well known c++ geek :)

Did I say anywhere C# was better?
Better in computer languages does not exist, for instance I find this language not bad;)

No i posted it to here to have Scott involved in the conversation.
Today he is in good mood. And also i really wonder how c# deals without having header files, if that can be done, why c++ has them, of course it cant be for bothering the programmer.

When am I not in a good mood!?

Danny -- To the point you made that is also available in C# it is just done a little differently. You can create an assembly full of interfaces (unimplemented methods, just like the header file) and give the assembly to your developers. They can each start implementing their respective methods. I couldn't image developing something like this to be honest. You'll usually miss something along the way. It seems so much easier to just shoot a few emails back and forth and establish the "middle ground" where your code meets up and goes from there. If you forget an interface then you have to go back in and add it, rebuild your assembly, distribute it to the team, hope everyone upgrades and you don't have two different versions of the interface floating around with different signatures, etc. How did this work for you?

Serkan -- I don't know that much about c/cpp to be honest. I 'grew up' on pascal and switched over to pascal with some other archaic languages along the way. I think the thread you posted gives some very good examples:

1.To improve build times.
2.To link against code without having the source for the definitions.
3.To avoid marking everything "inline".

Beyond that .. I don't know :(

commented: good point +5

Did I say anywhere C# was better?
Better in computer languages does not exist, for instance I find this language not bad;)

I was about to say something practical, then I read your link and lost it--:D

Did I say anywhere C# was better?
Better in computer languages does not exist, for instance I find this language not bad;)

I still write programs on my TI-85 during class sometimes :)

[edit]
"" what DdoubleD said. I read the link after I posted
[/edit]

@Scott No problem whatsoever. We where three guys sitting in a room with 3 computers. We talked to each other. I believe e-mail as we know it now had to be invented...

As less of a discussion answer, and more of a poke at a simple explanation.

header files are a type of include. so when you need some functionality in your program you don't have to start from scratch. Some code is available to start with, and when you program is compiled this is compiled into your application. So it has no prerequisites.

in C# you do the same thing. except you only reference the code that is already available, that code is the .net framework.

my opinion is C++ is better because it makes more portable applications, but C# is my favorite language because its very powerful yet easy to learn and understand.

in C# you want to write a line to console you use the console class of the System library. System.Console.Writeline("blah"); the system library is part of the .net frame work and is installed on the client computer prior to your application.

in C++ if you want to write a line to console you first include the header ostream, then you pass to the output variable the "cout" the text you want to show on the console, cout<<"blah"<< endl; . when the program is compiled, a copy of the ostream code is included in the executable needing no preexisting library.

So its practically the same thing, just if C++ looses its headers, then it will just be unmanaged C#... and who wants that? not me.

Text from Wiki -

A header file commonly contains forward declarations of classes, subroutines, variables, and other identifiers. Programmers who wish to declare standardized identifiers in more than one source file can place such identifiers in a single header file, which other code can then include whenever the header contents are required.

The C standard library and C++ standard library traditionally declare their standard functions in header files.

Newer compiled languages (such as Java, C#) do not use forward declarations; identifiers are recognized automatically from source files and read directly from dynamic library symbols. This means header files are not needed.

i find this thread so informative. keep posting guys, this is a very useful and enlightening discussion. thanks for your answers.

i created a thread in geeks lounge "what do you think would be milestone web-social-application?", i would like to hear your opinions about that thread. Thanks in advance.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.