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

  • Home
  • SEARCH
  • 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 760713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:45:03+00:00 2026-05-14T15:45:03+00:00

Possible Duplicate: Why would you ever want to allocate memory on the heap rather

  • 0

Possible Duplicate:
Why would you ever want to allocate memory on the heap rather than the stack?

Test2 *t2 = new Test2();
t2->test();

Test2 t3;
t3.test();

Why would I want to create a pointer object of type Test2? Why not just do non pointer version of Test2? Why would I want to do pointer objects?

Found answer here:

  • Why would you ever want to allocate memory on the heap rather than the stack?
  • When is it best to use a stack instead of a heap and vice versa?
  • When to use “new” and when not to in C++?
  • When should I use the new keyword in C++?
  • Proper stack and heap usage in C++
  • Stack, Static and Heap in C++
  • 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-14T15:45:04+00:00Added an answer on May 14, 2026 at 3:45 pm

    The reasons to use dynamic storage include (but probably not limited to)

    1. Manual control of the objects lifetime – the object will live until you explicitly destroy it
    2. Creating as many objects as necessary, when the final number of objects is only known at run-time (like number of nodes in a tree or number of elements in an array).
    3. Run-time control of the object’s type (like actual type of polymorphic object).

    When it makes no difference, it is always better to create the object using your t3 method. Don’t use dynamic memory unless you have to. But sometimes you really have to (see the reasons above).

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

Sidebar

Related Questions

Possible Duplicate: finding all numbers less than x in a BST How would I
Possible Duplicate: undef - Why would you want to undefine a method in ruby?
Possible Duplicate: Global int variable objective c I would like to create a global
Possible Duplicate: .NET file system wrapper library I would like to write a test
Possible Duplicate: How would you count occurences of a string within a string (C#)?
Possible Duplicate: What WPF books would you recommend? GUI's written using WPF seem to
Possible Duplicate: Complex CSS selector for parent of active child How would I make
Possible Duplicate: When to Use Static Classes in C# Questions in the title..........i would
Possible Duplicate: Maximum length of the textual representation of an IPv6 address? What would
Possible Duplicate: Number of occurrences of a substring in an NSString? I would like

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.