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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T19:56:16+00:00 2026-06-03T19:56:16+00:00

Are pointers to things that are allocated in other ways reasonably safe in C++?

  • 0

Are pointers to things that are allocated in other ways reasonably safe in C++?

Up to this point, I’ve been using STL containers (and in one case, an array, but that’s another question) for all my dynamic memory needs, so I hadn’t needed to explicitly use the new keyword. I’ve also been blithely using plain ol’ int *foo type pointers to reference things. Now I’m reading about smart pointers (I cut my teeth on Java, so I never had to worry about this before) and the conventional wisdom seems to be “bare pointers are bad, don’t use them.”

So how much trouble am I in? Can I safely keep using bare pointers, so long as the things they point to have other destruction conditions? Is it something I can get away with, but should avoid in the future? Or is it a disaster in the making that I should go fix post-haste?

  • 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-06-03T19:56:18+00:00Added an answer on June 3, 2026 at 7:56 pm

    Bare pointers are safe per se, it is the incorrect usage of them that is dangerous (and you can get carried away easily). Smart pointers are nifty and all, but some (shared_ptr) involve reference counting, which incurs a performance penalty. You should try to use the smart pointers where applicable but AFAIK using pointers is not considered a horrible mistake.

    You should be careful when referencing members of the STL containers as their addresses can change during relocation leaving you with strange bugs.

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

Sidebar

Related Questions

My understanding is that pointers can be used, among other things, to allow for
Basically, I have a block of memory allocated using malloc that I want to
I want to arrange things such that for a class Foo, this works: Foo
Do smart pointers handle down casting, and if not what is a safe way
Lately, I've been reading much about constructors from the well-received C++ FAQ . One
This is my first time using stackoverflow for a question, I have read a
I have a C structure that looks like this typedef struct event_queue{ Event* event;
I made a typedef for float arrays, like this: typedef float fooType[]; So that
Things seem to be working but I'm unsure if this is the best way
I have been using Visual Studio 2005 under Windows XP Pro 64-bit for C

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.