Thread: Need help with a class assignment

  1. #16
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    Quote Originally Posted by Elysia View Post
    This is wrong, wrong, wrong. First off, never use NULL.
    In proper code, all pointers will be initialized to nullptr
    nullptr is not supported until C++0x (except in C++/CLI), and he may not be allowed to use the new language extensions. also, GCC doesn't support nullptr yet, but VC++ 2010 does. I'm not sure about other compilers.

  2. #17
    Registered User
    Join Date
    Mar 2011
    Posts
    21
    Well since I couldn't get help from my professor or fellow students, I thought I should go to different forums and see if I could get help from any of them.

    But I have already specified in the other forums that my questions have been answered and that I do not need anymore help for now.

  3. #18
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by Elkvis View Post
    nullptr is not supported until C++0x (except in C++/CLI), and he may not be allowed to use the new language extensions. also, GCC doesn't support nullptr yet, but VC++ 2010 does. I'm not sure about other compilers.
    Language extensions sounds like non-standard things added to a language. But nullptr is standard, in the upcoming standard which is being finalized.
    So yes, I stand by that. If your compiler doesn't support it, then make a define.
    It's rather silly that GCC doesn't support it, as well. It is integral to the new standard library.
    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
    Mar 2011
    Posts
    21
    So for now, my program is running fine and my questions have been answered. Thanks to everyone who helped out.

  5. #20
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by EonsNearby View Post
    Well since I couldn't get help from my professor or fellow students, I thought I should go to different forums and see if I could get help from any of them.

    But I have already specified in the other forums that my questions have been answered and that I do not need anymore help for now.
    Crossposting is generally frowned upon. You can seek help from a forum, but do so one at a time. If, after a reasonable time, you do not receive a response from one, seek out others.
    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.

  6. #21
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by Elysia
    It's rather silly that GCC doesn't support it, as well.
    According to GCC's C++0x support table, it is supported in g++ 4.6.0, but that is a very recent release.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  7. #22
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    Quote Originally Posted by laserlight View Post
    According to GCC's C++0x support table, it is supported in g++ 4.6.0, but that is a very recent release.
    it's actually not an official release yet. it's still in development.

    since this is a class assignment, I would recommend sticking with NULL because that's what the teacher is likely to expect. most schools don't teach C++0x yet, and so aren't likely to accept code that uses new features.

  8. #23
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Schools will never go over to C++0x if no one pushes them. Use nullptr and show that it is correct.
    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.

  9. #24
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > Schools will never go over to C++0x if no one pushes them.
    Especially since half the schools on the planet are still stuck with TurbidCrap, which pre-dates ALL standards for C and C++.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  10. #25
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    >> So yes, I stand by that. If your compiler doesn't support it, then make a define.

    Naming defines after reserved words is basically a big no in terms of standards compliance. Besides, aren't you the one who insisted nullptr is more than #define nullptr (NULL) anyway? Why fake what you don't have?
    Last edited by whiteflags; 03-16-2011 at 05:40 PM.

  11. #26
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    What do you do when your compiler doesn't support nullptr and you have the latest, except scrapping it and getting a better one?
    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.

  12. #27
    Registered User
    Join Date
    Sep 2010
    Posts
    90
    FYI: Also asked here
    Just a thought ... out of a few hundred great C++ forums, being a member of at lease two should not be an issue with anyone what-so-ever. Sometime people is not available to help you because they my simply be too busy. So sometime, every now and then, you are FORCE to ask your other ONLY favorite forum in the world. Problem is, one should never join a third or a forth forum just because they talking code that is related to your most important question. So if you are lucky, you at the very lease have two to pray for while waiting for an response. with only two fingers crossed and not ALL four.

    btw: This is our subject for next week class

  13. #28
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    Quote Originally Posted by Elysia View Post
    What do you do when your compiler doesn't support nullptr and you have the latest, except scrapping it and getting a better one?
    considering the fact that the new standard was just made official a few months ago, you can't expect all vendors to have instant support for all of the new features. remember that MSVC is maintained and developed by a corporation that employs full time developers. the people who work on GCC are mostly volunteers, who have other jobs, and can't devote as much time to it as they would if it was their primary occupation.

  14. #29
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by Elkvis
    considering the fact that the new standard was just made official a few months ago
    Actually, the new standard has not yet been published.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  15. #30
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    Quote Originally Posted by laserlight View Post
    Actually, the new standard has not yet been published.
    which only serves to strengthen my point - thanks laserlight. I don't intend to start an argument or anything, but forcing people to conform to a standard that isn't even official yet is just silly. it's certainly useful to be aware of the new features supported by the upcoming standard, and familiarize yourself with them so you can use them when compilers inevitably support them, but since many don't, and since it isn't required of them, it might be a good idea to slow your roll a little bit on telling people that they have to write code that conforms to the new standard.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. class composition constructor question...
    By andrea72 in forum C++ Programming
    Replies: 3
    Last Post: 04-03-2008, 05:11 PM
  2. Replies: 3
    Last Post: 10-31-2005, 12:05 PM
  3. structure vs class
    By sana in forum C++ Programming
    Replies: 13
    Last Post: 12-02-2002, 07:18 AM
  4. i need help with errors in my assignment for class
    By azrael13302473 in forum C++ Programming
    Replies: 1
    Last Post: 07-04-2002, 06:02 PM