I think I finally understand OOP

This is a discussion on I think I finally understand OOP within the C++ Programming forums, part of the General Programming Boards category; OK, I was have the huge function, and I was going to break it apart and add sections of it ...

  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    411

    I think I finally understand OOP

    OK, I was have the huge function, and I was going to break it apart and add sections of it to a new module. In the new module I was going to add a function that took like a dozen variables, I thought that I might make a new class to hold this data, declare it dynamically and send a pointer to that class to the function in the module. It worked first time out.

    Dose this sound good, whats the overhead beside the function call? Should the members of the 'data transfer' class be pointers to the real values, and not the values them selves, would that boost speed?

    If I dynamically declare something in a constructor, and put the delete command in the destructor, do I have to implicetly call the destructor, or dose it get called with the program exits?

  2. #2
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,136
    nope, automatically called. At least that's what I think.

  3. #3
    Registered User
    Join Date
    Aug 2001
    Posts
    411
    I thought I had it figure out, but ive hit an indirection error.

    bool *key;
    key = new bool[128];

    bool GetKey(short i) {
    return *key[i];
    };

    I get an illegal indirection error on the return line?

  4. #4
    geek SilentStrike's Avatar
    Join Date
    Aug 2001
    Location
    NJ
    Posts
    1,141
    Code:
    bool GetKey(short i) { 
    return *key[i]; 
    };
    key[i] returns bool, *key[i] is illegal, cannot deference a non-pointer.
    Prove you can code in C++ or C# at TopCoder, referrer rrenaud
    Read my livejournal

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Finally Graduated
    By LuckY in forum A Brief History of Cprogramming.com
    Replies: 14
    Last Post: 06-01-2006, 01:04 AM
  2. Replies: 6
    Last Post: 12-21-2005, 02:49 AM
  3. I Think I Finally Get It!
    By LordVirusXXP in forum C++ Programming
    Replies: 2
    Last Post: 12-18-2002, 01:43 PM
  4. Finally, a New Contest! November 13+
    By ygfperson in forum C++ Programming
    Replies: 0
    Last Post: 11-13-2002, 08:06 PM
  5. I finally got...
    By SyntaxBubble in forum Windows Programming
    Replies: 1
    Last Post: 11-18-2001, 06:38 PM

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