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 3982718
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:33:42+00:00 2026-05-20T05:33:42+00:00

I wish to dynamically allocate set of objects (can be several hundreds). Part of

  • 0

I wish to dynamically allocate set of objects(can be several hundreds). Part of those objects are text fields. Because std::string offers nice string manipulations, I would prefer having the object member parameters of type std:string.

However, std::string is dynamically resizable object. To me, this goes against the dynamically allocated objects containing std::string: There could be allocated memory overflow, if the std::string gets larger than planned.

  • Can I kindly ask for advices whether std::string is suitable as a parameter for dynamically allocated objects?
  • How to manipulate with std::string, so there will not be memory overflow?
  • Is std::string suitable as a member parameter even if hundreds of objects will be allocated dynamically?
  • 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-20T05:33:43+00:00Added an answer on May 20, 2026 at 5:33 am

    Your question is a little difficult to parse, and sample code would have made that easier, I think. Am I right in assuming that you have a class that contains a string, like so:

    class foo {
      public:
        std::string str;
    };
    

    and you wonder how the string is resized? Let me try and explain:
    The size of objects of class foo is fixed. The size of the string member is also fixed, but it contains in its implementation a pointer to additional dynamic memory (someplace else) that it is growing or shrinking depending on the contents of the string. The implementation of std::string takes care of this for you, you don’t need to worry about it. There won’t be any memory overflow either – the string’s memory is a different block of memory from the block used by the foo-object, for example.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to implement an interface where users can dynamically enter text and
I wish to change the text of the hyperlink dynamically, and trigger the change
How can I set the height (dynamically) of the yellow <div id=box> to fit
I'm having an issue in my application. I wish to dynamically create several tabbed
I wish to access a variable named storedata while dynamically changing the objects event
I wish to iterate over a set but the contents of the set will
I wish to capture data from http://www.kitco.com/texten/texten.html : <html> <head> <title>Text Only Market Page</title>
So I am dynamically creating an image and I wish to get the image
I wish to retrieve the source of a website, that is dynamically generated upon
how can I dynamically load a class in Java with two parameters which are

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.