Like Tree9Likes

Questions about C++ and programming in general from a newbie

This is a discussion on Questions about C++ and programming in general from a newbie within the C++ Programming forums, part of the General Programming Boards category; Originally Posted by Fizzgig I'm guessing being intimidated with walls of technical text isn't quite the mindset you have in ...

  1. #16
    Registered User
    Join Date
    Jun 2005
    Posts
    6,671
    Quote Originally Posted by Fizzgig View Post
    I'm guessing being intimidated with walls of technical text isn't quite the mindset you have in mind. I firmly believe this will change with familiarity though.
    Well, no, being intimidated isn't what I had in mind. I was referring to the fact that some people are more comfortable with technical things than others, some people prefer pictures rather than words, and things like that. Familiarity does change the fear of new things though.

    Quote Originally Posted by Fizzgig View Post
    Another question I keep forgetting to ask: Are header files necessary? As someone from a Java 'background' (The whole one year of it =P), header files feel unnatural to me. The book I'm working from states I don't need them. I've looked online and on basically every forum where this comes up it ends up into some kind of fight/argument. Someone, I can't remember who and on what forum, stated that it's still useful in the sense that it helps with program maintainability. What are your thoughts on the usefulness/viability of headers?
    Depends what you mean by necessary.

    All the preprocessor does is substitute the contents of the header file in place of the #include directive, before the compiler sees the code. A C++ compiler will be just as happy with code from the preprocessor as it will be if you copy the contents of the header file verbatim into your source file. So, for the compiler, header files are unnecessary.

    Note that the preprocessor and the compiler are separate phases of the process of turning a C++ source file into an object file. The preprocessor does text substitution that changes source code. The compiler gets into the act later.

    The value of header files is that they provide a convenient way to reuse code (typically declarations) in multiple source files. Programmers find it easier to type #include "someheader.h" than they do to repeatedly copy and past a thousand lines of text into multiple source files. Programmers also find it easier to edit someheader.h (and have their changes be seen by the compiler when processing ALL of their source files) than to edit content that has been duplicated across multiple source files. Making exactly the same change in multiple source files is tedious, boring, and error-prone. For humans. That is, in essence, the maintainability argument.

    In C++ (and C) it is generally preferable to use the standard header files (<iostream>, etc) rather than copy and past the code from those headers into your source files. The contents of standard headers are implementation dependent (i.e. can vary between compilers), so a "copy and paste" approach can yield code that works with one compiler but not another.

    Incidentally, you might want to contemplate the import keyword in Java. It is not equivalent to the #include preprocessor directive in C++, by any means, but there are aspects in common.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Sunshine, and read this, this, and this before posting again.

  2. #17
    Registered User
    Join Date
    Aug 2012
    Posts
    10
    Hi folks,

    I'm a little too excited to reply to this thread at the moment, because I began work on a program minutes after my last post and I finished it literally 5mins ago. I'm sure this program would take all of you like an hour to write yourselves (if not less), but it took all my free time between then and now. I can't wait to see how if fares in your eyes. I will be coming back and editing this post with a proper reply to all of you once I have posted my program in a different thread

    If you are reading this sentence; imagine me frantically hammering away at the keyboard typing up another thread and you won't be too far off the truth.

  3. #18
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,029
    You only have an hour to edit your posts - so you'd better be quick if you're excited about it!
    ...But if the time expires, posting again (making it a double post) is not so bad so long as you don't overdo it. Just make sure you have a good reason to do it.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #19
    Registered User
    Join Date
    Aug 2012
    Posts
    10
    Quote Originally Posted by rogster001 View Post
    P.S. The fact that there are no headers in java is a source of much rage for me!!!!! I have to say i dont like the big jv much mate. Its just a shame C++ cant match it in some areas - natively i mean - but then depending on a big lump of runtime being available on the target platform is not exactly cool either.
    For me Java has the simplest and most intuitive syntax. It would be my favourite language if only is wasn't so horrendously slow. But then again, I'm not exactly a great judge and it was my first language, so that probably biases me.

    Quote Originally Posted by Elysia View Post
    You only have an hour to edit your posts - so you'd better be quick if you're excited about it!
    ...But if the time expires, posting again (making it a double post) is not so bad so long as you don't overdo it. Just make sure you have a good reason to do it.
    That... would explain it. Just went to get a glass of water after writing that post and when I got back; no more editing option. Still cannot believe it took me an hour to write that thing. Too bad my coding skills weren't really up to par. Reading the feedback on there it becomes clear pretty quickly that I'm writing terrible code on pretty much every level.

    Mini-rant: You know, it's not the fact that almost everything I've been taught up to this point has been wrong and that consequently I've been wasting my time that frustrates me. It's the knowledge that this is going to continue to happen and I can't do anything about it. I went to see my teacher yesterday to ask about the compiler and such. He told me we use it because it's what's used at our universities, so... yeah. Having said a year and a bit was a bit premature. /end rant

    I came to the same conclusion you had Elysia after that conversation: To go and try to find a happy medium. I think it's best I lock myself away in a room for a two months or so and relearn everything from the ground up before I post code again. Not that your feedback put me off or anything, I just realize my basics isn't what it should be. I mean, it's not fair to you guys right? All the "How to" stuff related to this is already on the net and nobody signed up to this forum with the idea in mind to become volunteer tutors (I don't think?). I'm just going to need some recommendations before I can get started on that - but I will ask about that in the other thread. Hopefully help someone else out with the same problem as me.

    This should really be in a PM, but I can't do those yet and I don't want to spam to make up the post count. Plus I want to say this ASAP:
    To iMalc: Someone pointed out to me my attempt at self-depreciating humour doesn't translate well into some cultures. If that's true, it now occurs to me that my reply could have been misunderstood as rude or disrespectful. I didn't mean it that way and if you understood it as such I apologize.

  5. #20
    Registered User
    Join Date
    Jun 2005
    Posts
    6,671
    Quote Originally Posted by Fizzgig View Post
    For me Java has the simplest and most intuitive syntax. It would be my favourite language if only is wasn't so horrendously slow. But then again, I'm not exactly a great judge and it was my first language, so that probably biases me.
    Yes, indeed. You're not alone in being biased by your experience first programming language.

    In my experience, there is almost a 100% strike rate for such a bias: virtually everybody learning a second programming language complains about the deficiencies of that second language, and claims that the first language they learn was simplest, the most intuitive, has the best syntax, is least error prone, is the safest, is the most useful .....

    That sort of bias, for a lot of people, endures until they have learned four or five languages, assuming they have achieved a good level of proficiency in at least two and preferably three of them. Once they reach that point, they realise that ALL programming languages have their strengths and deficiencies. Unfortunately, many programmers never reach that point, and never realise how uninformed their criticisms of programming languages really are.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Sunshine, and read this, this, and this before posting again.

  6. #21
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,415
    In my experience, there is almost a 100% strike rate for such a bias
    It didn't hit me, but then "Apple BASIC" was my first language. ;_;

    Soma
    Elkvis likes this.

  7. #22
    Registered User
    Join Date
    May 2012
    Location
    Arizona, USA
    Posts
    383
    Quote Originally Posted by phantomotap View Post
    It didn't hit me, but then "Apple BASIC" was my first language. ;_;

    Soma
    Same here, but Commodore BASIC was my first. Of course, they were both made by Microsoft, and I can't really say that anything they make is the best in any category.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Newbie C programming questions
    By moussa in forum C Programming
    Replies: 4
    Last Post: 04-10-2012, 03:17 AM
  2. Game Programming general questions... and Math?
    By MsJordan in forum Game Programming
    Replies: 15
    Last Post: 11-06-2010, 08:46 PM
  3. [Newbie] Quick general questions about C#
    By PaulBlay in forum C# Programming
    Replies: 1
    Last Post: 06-17-2009, 09:14 AM
  4. Password program / general programming questions
    By plr112387 in forum C++ Programming
    Replies: 13
    Last Post: 11-04-2007, 10:10 PM
  5. a few opengl(or general programming) questions
    By linuxdude in forum Game Programming
    Replies: 20
    Last Post: 06-14-2004, 08:47 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21