Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6236509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:51:58+00:00 2026-05-24T10:51:58+00:00

I am doing this learning/practicing with arrays of objects and array of pointers to

  • 0

I am doing this learning/practicing with arrays of objects and array of pointers to objects and I’m very confused about how to get dynamic arrays sizes.

I’ve got this:

private: 
    Client ** arr_client;

public:
    static string  members [];

then populated the array arr_client with tokenized data from the following static string array members:

static string members[] = {"Jhon Perez 623 22 12 1998"
                          ,"Louis Smith 199 02 12 1988"
                          ,"Daniel Martinez 106 02 01 2010"};


void load(void){

arr_client = new  Client * [(sizeof(members)/sizeof(string))*sizeof(Client)];

    for (i = 0; i < (sizeof(members)/sizeof(string)); i++){
        istringstream stream(members[i],ios_base::in);

        stream >> name;
        stream >> lastname;
        stream >> aux;
        id = atoi(aux.c_str());
        stream >> date;
        date.append(" ");
        stream >> aux;
        date.append(aux);
        date.append(" ");
        stream >> aux;
        date.append(aux);

        arr_client[i] = new Client(name,lastname,id,date);
    }
}

now, after the object array is full, I want to loop through arr_client but I cant seem to find the way to do it.

should I use:

for (int i =0; i < (sizeof(**arr_client)/sizeof(client)); i++)

or take the previous cal for size and do:

for (int i =0; i < (sizeof(members)/sizeof(string)); i++)

and be done with it? doesn’t look that usefull to me… but then again I’m very new.

Few questions I’ve also got:

What if I don’t know the size of that dynamically assinged array of objects? like in this case that im building upon a known sized array.

How can count how many elements are in it so I could loop through it?

Could I use an std::iterator for arr_client?

Any tips would be much appreciated =)

and…. yes, I do know about <vector> and it’s advantages but never hurts to know about these scenarios.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T10:52:00+00:00Added an answer on May 24, 2026 at 10:52 am

    First, I applaud you for trying to learn the fundamentals before adopting an advanced tool like vector.

    There’s no clean and reliable way to do what you ask. People usually remember the size of an array in a separate variable, like this:

    unsigned int num_strings=3;
    static string  members[num_strings];
    

    If you really want to determine the size of an array at runtime, you can do it with a template:

    template<typename T, size_t N>
    size_t arraySize( T(&)[N] )
    {
      return(N);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I've been working on learning LINQ, and I think I'm doing this correctly,
Sorry i'm new to .net and learning so this may be very simple. I
I'm very new to this version control business and slowly learning my way. I've
I am doing this as learning and I have been told that NSString return
I'm learning Java and OOPS from oracle's website. I'm doing this exercise . I'm
I'm still learning Perl, so there's probably a more efficient way of doing this.
Still learning JSP Web Applications here. I have been doing this for a while
Im doing this project where i need to download files through a webservice (images,
I have some code doing this : var changes = document.getElementsByName(from); for (var c=0;
I'm doing this system Stacked and I am creating the search function. And in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.