Like Tree1Likes

Looking for constructive criticism

This is a discussion on Looking for constructive criticism within the C++ Programming forums, part of the General Programming Boards category; Originally Posted by skyliner Well, my new IDE has many options under the "Compiler and Debugger" setting. I enabled -Wall, ...

  1. #31
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,020
    Quote Originally Posted by skyliner View Post
    Well, my new IDE has many options under the "Compiler and Debugger" setting. I enabled -Wall, -Wextra and -pedantic. I also found optimization options. It's astonishing how many features I can control form there.
    That's good. But leave the optimization features off unless you intend to run the program on another computer. The optimizations make debugging harder.

    Could you be so kind and explain why ? I find rather convenient to do the first.
    It essentially creates global variables, which are considered Evil™.

    Right, would it not be better to pass a specific member instead of the whole structure though?? I.E sub.shape vs sub.
    You could, and in fact, I'd say it's better, but in time you will end up with so many variables to a function it will just make it difficult to read, type and maintain. At this point, you could just pass in a struct or an object.

    Wouldn't the compiler warn you or something ?
    Seriously, Rectangle. What namespace Rectangle belongs too ?
    In case of collisions, yes, you will get an error.

    Would you please elaborate ?
    Essentially it means that it is the optimum size for the processor, so that it can process it as fast as possible.
    Each register in the cpu is a certain size, depending on your cpu architecture. If you try to add two 64-bit numbers on a 32-bit cpu (32-bit registers), it will take longer than if you add two 32-bit numbers (or below).
    Nevertheless, this is all implementation defined (read: compiler vendors do whatever they want), so don't read too much into it.

    Very illustrating. I still have doubts on how to use unicode on my program though. Do I have to use a special processor directive, include a specific library ?? I'll have too look it up on the web.
    It all depends on your compiler. In case of using the mingw compiler, you typically have to use wchar_t. If you can use C++11, there are specific types dedicated for unicode, but I don't know if mingw supports them.
    Then you have to remember to call the appropriate functions. For example, wcout instead of cout.
    That's enough to get you started, but internationalization is, as they say, a big field, and a complex one.

    If we follow that logic then why bother using bools at all. We should use integers/longs for everything that doesn't need decimals.
    We don't do it for the size. We do it for the convenience and the message it implies.
    If you use a bool, then we know it only takes true of false, not some limited real number range.
    Also, in some languages, integers are not implicitly converted to booleans like in C++.
    so if (5) would yield true in C++, but wouldn't work in Java.
    Why? Because an integer is not a boolean expression.

    I'm curious however, is there any performance gain by doing it that way or is is just for convenience ?
    Performance gain is debatable. It all depends on how well the compiler optimizes the code, so don't worry about it.
    But it certainly beats coding a long switch case.

    Also, how are the strings typed in the source code, stored and later retrieved during runtime ?
    In this case, they're typically stored in a read-only area inside your executable.

    For me, using code::blocks for the first time was a little different, it required creating a "build target' 'debug' and 'release' configurations and manually creating a source file. Definitely much more work than in devC++. This could be daunting for a newbie. Though not too much.
    True, but in our defense, remember that in the real world, you will almost always happen upon a big program with thousands on menu items with no idea how to use it. But you will need it for whatever work you are to do.
    So I'd consider it as a good exercise. All the school need to do is create a beginner's tutorial to get the students started.
    skyliner likes this.
    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.

  2. #32
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,762
    Quote Originally Posted by skyliner View Post
    Wouldn't the compiler warn you or something ?
    Seriously, Rectangle. What namespace Rectangle belongs too ?
    One of the reasons that particular error took me so long was because I couldn't find where the other rectangle was. It was apparently a name in the global namespace. (For example use ::global_name, if you need to clarify.) I couldn't find it in any of the headers I was using. Looking back, I had a lot of options. I could have made my own namespace, but I ended up renaming the type with a global edit.

  3. #33
    Registered User
    Join Date
    Jul 2012
    Posts
    23
    Thank you very much guys. I greatly appreciate all your help and feedback.

Page 3 of 3 FirstFirst 123
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Looking for constructive criticism
    By wd_kendrick in forum C Programming
    Replies: 16
    Last Post: 05-28-2008, 10:42 AM
  2. Constructive criticism/suggestions
    By LineOFire in forum C Programming
    Replies: 11
    Last Post: 09-30-2006, 10:32 AM
  3. Constructive criticism, suggestions etc
    By BobS0327 in forum C Programming
    Replies: 3
    Last Post: 01-08-2006, 09:35 AM
  4. Constructive criticism highly appreciated!
    By muggizuggi in forum C++ Programming
    Replies: 17
    Last Post: 08-01-2005, 12:54 PM

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