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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:34:18+00:00 2026-05-18T10:34:18+00:00

Hi there i have some questions about pointers and arrays in c++: when i

  • 0

Hi there i have some questions about pointers and arrays in c++:

when i want to pass an array of pointers in a function i must write:

foo(test *ptest[])

right?

when i want to delete a array of pointers, does

delete ptest;

all for me?

when i pass a pointer to another class and the first class make a delete, the pointer is deletete in all classes right?

must i always create a array of a constant size?

  • 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-18T10:34:19+00:00Added an answer on May 18, 2026 at 10:34 am

    First of all, forget about arrays and pointers and tell us what you really want to achieve. You are probably better off using std::vector<T> and pass that around by (const) reference, saving you all the headaches of manual resource management and crazy array-to-pointer-decay rules inherited from C.

    Now to answer your questions:

    when i want to pass an array of pointers in a function i must write:

    foo(test *ptest[])
    

    right?

    Yes, but remember that array parameters are always rewritten by the compiler to pointers. Your code is equivalent to:

     foo(test **ptest)
    

    This means that all information about the size of the array has been lost. Moving on:

    when i want to delete a array of pointers, does

    delete ptest;
    

    all for me?

    No. If you acquire via new[], you must release via delete[], otherwise you get undefined behavior. Note that deleting an array of pointers only gets rid of the array itself, not any objects pointed to by the pointers stored inside the array.

    Again: Forget about arrays and pointers and use the facilities provided by the C++ standard library.

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

Sidebar

Related Questions

There have been some questions about whether or not JavaScript is an object-oriented language.
I have some questions about the object size with virtual. 1) virtual function class
There have been some similar questions asked regarding Grid views, but none have been
I know there have been some similar questions to this, but they haven't helped
I have some jQuery/JavaScript code that I want to run only when there is
I have some questions about the concept of static polymporhism I somethimes hear about;
Is there a way to have some kind of default constructor (like a C++
I have some VirtualBox VMs running. Is there any way to programatically get the
I have some localization problems in my webpage. There are basically two problems (that
We have some old C code here that's built with nmake. Is there an

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.