What imperfections of the code?

This is a discussion on What imperfections of the code? within the C++ Programming forums, part of the General Programming Boards category; What imperfections of the code? Code: void MyClass(int a) { int *x = new int[a]; int *y = new int[a]; ...

  1. #1
    Registered User
    Join Date
    Sep 2009
    Posts
    1

    Question What imperfections of the code?

    What imperfections of the code?

    Code:
    void MyClass(int a) 
    {
        int *x = new int[a];
        int *y = new int[a];  
        Bar(x, y);    
        delete [] x;
        delete [] y;
    }
    Thanks!

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    I don't know. Why should there be something wrong with it?

  3. #3
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,699
    What imperfections of the code?

    Code:

    void MyClass(int a)
    {
    int *x = new int[a];
    int *y = new int[a];
    Bar(x, y);
    delete [] x;
    delete [] y;
    }

    Thanks!
    Smells like homework. Think "exceptions".

  4. #4
    Registered User
    Join Date
    Jun 2005
    Posts
    6,259
    There is also a question of how descriptive the code is of what it does. What is x, y, .... ?
    Right 98% of the time, and don't care about the other 3%.

  5. #5
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,438
    A function named 'MyClass'.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  6. #6
    Dae
    Dae is offline
    Deprecated Dae's Avatar
    Join Date
    Oct 2004
    Location
    Canada
    Posts
    1,034
    Quote Originally Posted by Mario F. View Post
    A function named 'MyClass'.
    I'm sorry, but I have to post my LOL at that..

    Edit: I'm not disagreeing, I thought your observation was funny and how bluntly you put it. Good observation.
    Last edited by Dae; 09-12-2009 at 08:15 AM.
    Warning: Have doubt in anything I post.

    GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101

  7. #7
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,438
    Well, that's all we are allowed to see. A function.
    Last edited by Mario F.; 09-12-2009 at 07:52 AM.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Extended ASCII Characters in an RTF Control
    By JustMax in forum C Programming
    Replies: 18
    Last Post: 04-03-2009, 08:20 PM
  2. Enforcing Machine Code Restrictions?
    By SMurf in forum Tech Board
    Replies: 21
    Last Post: 03-30-2009, 07:34 AM
  3. Obfuscated Code Contest
    By Stack Overflow in forum Contests Board
    Replies: 51
    Last Post: 01-21-2005, 03:17 PM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM
  5. Replies: 0
    Last Post: 02-21-2002, 05:05 PM

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