For direct access use https://forums.oldunreal.com
It's been quite a while since oldunreal had an overhaul, but we are moving to another server which require some updates and changes. The biggest change is the migration of our old reliable YaBB forum to phpBB. This system expects you to login with your username and old password known from YaBB.
If you experience any problems there is also the usual "password forgotten" function. Don't forget to clear your browser cache!
If you have any further concerns feel free to contact me: Smirftsch@oldunreal.com

What's the difference between...

Unreal Unreal and more Unreal
Post Reply
User avatar
Rarsonic
OldUnreal Member
Posts: 123
Joined: Mon Jul 04, 2005 3:46 pm

What's the difference between...

Post by Rarsonic »

The headers (public) and the sourcecode?

Kind-of a noob question, I know... :P
<><>Gibberish
User avatar
Smartball
Global Moderator
Posts: 241
Joined: Fri Mar 22, 2002 4:01 am

Re: What's the difference between...

Post by Smartball »

Although it's possible to put source code in header files, they are typically used for putting declarations in without giving any detail as to the implementation. The implementation code is then put in source files. This allows you to know what sorts of functions you can call on certain classes without having to know how they are implemented, and also allows you to declare something in one header file and then reuse it in multiple source files. So if I provide a header file and a compiled source library, you can use my header file to know how to interface with the classes in my library without having to know how I implemented any of it. The real gain is greater encapsulation and code reusability.
Of all the things I've lost, I miss my mind the most.
User avatar
[§Ŕ] ŤhěxĐâŕkśîđěŕ
OldUnreal Member
Posts: 4425
Joined: Wed Sep 03, 2008 8:19 am

Re: What's the difference between...

Post by [§Ŕ] ŤhěxĐâŕkśîđěŕ »

So, in Java aspect, header=interface/abstract class and source sode=class?
User avatar
Bane
OldUnreal Member
Posts: 493
Joined: Sun Mar 03, 2002 6:32 pm

Re: What's the difference between...

Post by Bane »

I suppose that's a decent analogy, except you have headers for (just about) every function, while you don't need every class to be the subclass of an abstract class.

For the most part, headers are just the function and class definitions, but with out the body of the function.
Like "int incrementByOne(int n);"
instead of

Code: Select all

int incrementByOne(int n)
n = n + 1;
return n;
Basically you can see the name and call the function, but you can't see exactly how it works (you're left at the mercy of the documentation).
Author of Hide and Seek mod, and the NALIBALL mod

Hide and Seek can be downloaded from:
http://HideNSeek.5u.com
User avatar
Smartball
Global Moderator
Posts: 241
Joined: Fri Mar 22, 2002 4:01 am

Re: What's the difference between...

Post by Smartball »

So, in Java aspect, header=interface/abstract class and source sode=class?
Not exactly. Java makes no distinction between a header and source. The idea of a header file is not comparable to Java's interfaces and abstract classes because interfaces and abstract classes are actual parts of the programming language, whereas a header file is a list of declarations. They exist for fundamentally different purposes. You can't "implement" or inherit from a header file, that doesn't make sense. The header provides information to the compiler to let it know what it's allowed to do with the compiled code.

In Java, a declaration cannot exist without a definition. The only exceptions to this rule are declaring a method with no body inside of an interface or declaring an abstract method. However, this still does not make interfaces comparable to header files because they are setting up a base for derived classes to inherit from. They are not necessarily specifying an API for something that exists. And furthermore, the interfaces and abstract classes that something may inherit from are not distributed separately from the rest of the compiled code - the reason being, abstract classes and interfaces ARE source code in Java.

When you want to use someone else's compiled Java code, it typically requires you to read some sort of documentation to see what the classes' APIs are (I'm speaking in principle, this is ignoring the fact that java bytecode is decompilable). Distributing a C++ library requires the inclusion of compiled code and header files, because C++ makes a strong distinction between a declaration and a definition. Without the header files, a C++ compiler can't use the compiled code because none of it would be declared. A Java library just requires the inclusion of compiled code because there is no such thing as separating a declaration from its definition in Java. So, as I said, to know how to use that compiled code, you'd need some sort of documentation explaining the available API. It's always nice to have additional documentation for a C++ API as well, but that documentation can exist in the header files themselves.
Last edited by Smartball on Thu Mar 12, 2009 12:27 am, edited 1 time in total.
Of all the things I've lost, I miss my mind the most.
User avatar
GreatEmerald
OldUnreal Member
Posts: 5347
Joined: Mon May 21, 2007 2:30 pm

Re: What's the difference between...

Post by GreatEmerald »

So basically we can't see the Source Code, but we can see headers, even here on our forums: http://www.oldunreal.com/cgi-bin/yabb2/YaBB.pl?num=1202460562/60#60
Post Reply

Return to “Unreal General Forum”