Thread: How do I make a function that accepts an array of objects as it's argument

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    > There's no need for an array dimension to be a constant size.

    It does when the array is not being dynamically allocated, which was the case at hand. There's also of course the situation where an array is initialized explicitly as in:

    Code:
    int array[] = {1, 2, 3};
    But then and again no dimension is being given.

    After C99 gets incorporated into C++, then there will be no longer this requirement.
    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.

  2. #2
    Registered User
    Join Date
    Jan 2006
    Posts
    49
    Actually, I will eventually need to make a dynamic array of objects.

    I was hoping to create a function that would take the array and find the nearest empty slot with which to place the next object. That was what I was hoping to turn the function into. I figured first that it would have to accept an array.

  3. #3
    Registered User
    Join Date
    May 2003
    Posts
    1,619
    Quote Originally Posted by rakan
    Actually, I will eventually need to make a dynamic array of objects.

    I was hoping to create a function that would take the array and find the nearest empty slot with which to place the next object. That was what I was hoping to turn the function into. I figured first that it would have to accept an array.
    Use std::vector and push_back() the new entries.
    You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 05-13-2011, 08:28 AM
  2. <Gulp>
    By kryptkat in forum Windows Programming
    Replies: 7
    Last Post: 01-14-2006, 01:03 PM
  3. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  4. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM
  5. Hi, could someone help me with arrays?
    By goodn in forum C Programming
    Replies: 20
    Last Post: 10-18-2001, 09:48 AM