Jump to content
Ghost Recon.net Forums
Sign in to follow this  
firefly2442

C++ Noob Question

Recommended Posts

In C++... what is the difference between a ".h" header file and a ".c" source file? Thanks. Does anyone here do any C++ programming?

Share this post


Link to post
Share on other sites

The header file contains precompiled information from code libraries and such.

The source file is what you create after it's compiled into a program.

The source file is all the code you wrote to create a program.

Share this post


Link to post
Share on other sites

I've got a n00b C++ question too....

Where can I find a book that actually helps?

Share this post


Link to post
Share on other sites

learn some BASIC

learn some C

then you'll have a much better chance of getting C++

gotta learn to walk before you run

Share this post


Link to post
Share on other sites

A header will have only function and object definitions, as in the headers (that's why its a header file). The header file will then include its source which has all the actual functions and constructors and such.

Share this post


Link to post
Share on other sites
learn some BASIC

learn some C

then you'll have a much better chance of getting C++

gotta learn to walk before you run

Not really so true. I learned VB then C++. Your way is kinda like walking, running with one foot, then running with 2.

Share this post


Link to post
Share on other sites

Java is similar to C++ as I've heard and I pretty much know Java now (from college courses). So I hope I'll be ok. :) Thanks for the help.

Share this post


Link to post
Share on other sites

So lemme try this out, in Java, the whole "an object is an instance of a class" thing. This is kinda similar except from the code you are including these headers which have all this information and code to setup variables and so on in them? Does that make sense?

Share this post


Link to post
Share on other sites

I'd heard I should learn Java before... I'll see if I can try that.

Share this post


Link to post
Share on other sites
learn some BASIC

learn some C

if you're learning, start with anything that is OOP based. learning logic and program flow can be done in any language. Starting with OOP instead of migrating to it will make your future programming experiences conceptually easier.

That said, C is still used by professionals, esp in game coding, so being familiar with C wouldn't hurt at all.

Share this post


Link to post
Share on other sites

It seems like the colleges are starting out with Java. Is this the case that most of you who have started out recently seen? I assume this is because it is Object Oriented.

http://www.cs.nps.navy.mil/people/faculty/...97/java_ans.htm

Article my Java teahcer gave the class.

Something to think about when you are paying all that money for your Java class.

Share this post


Link to post
Share on other sites
The yellow burns my eyes...

Copy and paste it somewhere then.

Edited by Matt03

Share this post


Link to post
Share on other sites

Quote from article:

In horrible C tradition, Java arrays start from zero, instead of one. How many future programmers will spend hours locating off-by-one errors? What is wrong with the number one?

This is SO true. I've been studying graph algorithms, search algorithms, sort algorithms, I'm up to my eyeballs in algorithms and let me tell you, if I had a dollar for every time I was off on my index by one...... grrrrrr

Share this post


Link to post
Share on other sites

It is a number but it is a lot easier to understand when you start at one.

It is just easier for people to think starting at one than zero. Think about it. When you start counting you don't start at zero do you?

Share this post


Link to post
Share on other sites
It is a number but it is a lot easier to understand when you start at one.

It is just easier for people to think starting at one than zero.  Think about it.  When you start counting you don't start at zero do you?

Not out loud, no. But you can and some do when counting money, and everything related to a PC can or does start with a zero; zero actually counting as a number.

Zero doesn't mean 'nothing' in the computer world.

Share this post


Link to post
Share on other sites

But aren't we talking about a computer language used by people?

Share this post


Link to post
Share on other sites
But aren't we talking about a computer language used by people?

We're talking about a computer language used by computers, but is entered by people. Subtle difference. Zero is a logical character, and computers are logical by design, thus programmers have to work with the inherent logic of the hardware/software when writing code.

To put it this way: In English, other than pronouns, gender has no role. In French, nouns are masculine or feminine. In German, it's like French, but there are Neutral gender words. The speaker must adapt their format to suit the platform/language/nation/whatever they are communicating with.

Share this post


Link to post
Share on other sites

But shouldn't writing a program be easier for the programmer? The computer doesn't care if the array starts with 0 or 1. So why not start with the one that is esaier for people to understand.

Share this post


Link to post
Share on other sites

why is it harder to start with 0?

anyone who uses computers a lot and knows a fair bit about what's behind them e.g binary, hex etc starting with a 0 is normal

Share this post


Link to post
Share on other sites

I'd like 2 as the start, but it all comes down to binary, so you 0 and 1 freaks get it all.

Edited by DonMiguel

Share this post


Link to post
Share on other sites

Maybe the only problem that I have is the variable lenght that is created when the array is created. It is set to the value that you say i.e. (int[] i = new int[25]) lenght will be 25 while the array only goes from 0-24.

Edited by Matt03

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×