Thread: New typecast Style in C++?

  1. #16
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Quote Originally Posted by orbitz
    You seem to be confusing the requirement of pointeres to accomplish things in C++ with pointers being a good thing. Just because C++ lacks decent means of accomplishing the task doesn't mean it's a very good way.
    Pointers ARE a good thing in the hands of a skilled programmer.

  2. #17
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    There are many cases in c++ where it is not possible to avoid casting. Probably the most common reason is downsizing a c++ class to one of its parents. There are literally thousands of examles where that is needed. I wouldn't say casting is bad at all -- you might as well say inheritence and polymorphism are bad and don't do either.
    Last edited by Ancient Dragon; 09-19-2005 at 08:40 PM.

  3. #18
    Registered User
    Join Date
    Nov 2002
    Posts
    491
    Pointers ARE a good thing in the hands of a skilled programmer.
    I find this argument to be fairly weak, personnely. Anything can be made to be good in the hands of a skilled individual. I think it is probably more important to discuss how much work it takes to prove the correctness of something. That way you can avoid how skilled the user of it is and focus on how well the tool solves your problem. Pointers are impossible to prove teh correctness of them when using. I don't mean prove correctness in the mathematical sense (since most programming langauges lack this, except maybe ML's). But rather, how much work it takes to be reasonbly sure you have not commited undefined behavior somewhere. And with pointers you, really, cannot be 100% sure of this. Another problem is, god forbid this magically skilled programmer, makes an error, pointers are very difficult to track down the error and properly solve it.

    I wouldn't say casting is bad at all -- you might as well say inheritence and polymorphism are bad and don't do either.
    Polymorphism and inheritence can be implemented without allowing one to perform undefined behavior (i.e safely). Casts do not gurantee you have performed a safe operation, this is why langauges such as ML and python do not have any concept of casting, so i think your comparision is poor.
    Last edited by orbitz; 09-19-2005 at 09:35 PM.

  4. #19
    Registered User
    Join Date
    Nov 2002
    Posts
    491
    Also, there is no way to recover from an error caused by misuse of a pointer. One would think that would win over even the most fanatical pointer supporter.

  5. #20
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Quote Originally Posted by orbitz
    I find this argument to be fairly weak, personnely.
    At least I am attempting to make a case, which you really haven't done at all. All I've heard from you is opinion.
    Quote Originally Posted by orbitz
    And with pointers you, really, cannot be 100% sure of this. Another problem is, god forbid this magically skilled programmer, makes an error, pointers are very difficult to track down the error and properly solve it.
    There is a myriad of tools avialable to track down out of bound memory access. Its really not that hard to find these errors if they occur.

    Quote Originally Posted by orbitz
    Also, there is no way to recover from an error caused by misuse of a pointer. One would think that would win over even the most fanatical pointer supporter.
    Actually there is. You can capture the seg fault signal and keep the program from terminating. Also good coding habits and knowledge of how to use pointers correctly prevent this from being an issue.

    I suggest you really take some time away from your position and school yourself some more.

  6. #21
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    And since you know what: Mister C's question was answered lets just end this here.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WM_CAPTION causing CreateWindowEx() to fail.
    By Necrofear in forum Windows Programming
    Replies: 8
    Last Post: 04-06-2007, 08:23 AM
  2. Button handler
    By Nephiroth in forum Windows Programming
    Replies: 8
    Last Post: 03-12-2006, 06:23 AM
  3. Which style of if loops is most common?
    By dwks in forum A Brief History of Cprogramming.com
    Replies: 38
    Last Post: 08-25-2005, 03:18 PM
  4. WS_EX_COMPOSITED style (double buffering) problems
    By JasonD in forum Windows Programming
    Replies: 2
    Last Post: 10-12-2004, 11:21 AM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM