Learning C++

Since I’ve been wanting to do this for a long time, I’m reading a C++ tutorial. While I have an idea of programming in C++, I have never really sat down to learn all the basics. In reading the tutorial, I’ve noticed that in C++ there are 10 ways to do everything. My favorite examples are:
int a (5) is the same as int a = 5

a = 2 + (b = 5); is the same as
b = 5;
a = 2 + b;

I think that this is one of the reasons C++ code is always so much harder for me to read than Java. I personally think that Java’s syntax seems more consistant, but they do have their inconsistancies also. For example:

word.length(); //Checks the size of the String word.
array.length; //Checks the size of array.
arrayList.size(); //Checks the size of the ArrayList arrayList.

4 Responses to “Learning C++”

  1. September 16th, 2005 | 11:27 pm

    Hmm, I actually find easier if there are 10 ways to do something than if there were only 1.
    I guess is something you will agree with me when you go ahead learning, is better to have different ways to do something rather than having only 1.

  2. marv
    September 22nd, 2005 | 2:27 pm

    I see what you mean, but it adds to the confusion if you ask me. While some notations may shorten the syntax, they make it hard for others to follow the code. I’d rather write code that is as readable as possible and leave the optimizing to the compiler (which from what I’ve read, most modern compilers do such optimizations already).

    Now that I’ve been programming in C++ for a couple of months, I’ve actually found out that int a(5) and int a = 5 aren’t quite the same thing, at least not the compiler.

    And I don’t see how it can be easier for you to do something if there are 10 ways in doing it and all 10 ways end up to the same thing.

  3. Hades
    November 13th, 2005 | 4:00 pm

    I think its ok to have 10 ways to do the same thing just because when you are programming, you don’t have to think to much. The problem is when you’re trying to understand somebody else’s code. That happened to me recently.. I was trying to use somebody else’s code to write mine, and I wasted so much time trying to understand…
    But for me, I think it’s good to have many ways of doing things, so you can remember what seems logical to you, dont you think?

  4. Deska
    June 3rd, 2007 | 2:55 pm

    I’m 15 years old and I learn C++ programing at school.It’s not very difficult at all.

Leave a reply