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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:12:15+00:00 2026-06-12T14:12:15+00:00

I am developing a game using C++. I’ve read in a lot of places

  • 0

I am developing a game using C++. I’ve read in a lot of places that using pointers in C++ should basically be avoided at all costs. I am still learning C++ and slightly confused by this.

I would like a player object that is persistent and lives for the duration of the game session. This object will contain the players inventory, player stats etc etc.

The player’s inventory is basically just a vector containing item objects (an ‘Item’ class I’ve created).

If someone can clarify the following it would clear up my confusion:

  1. When people say ‘pointers are bad’ do they mean standard C++ pointers? Are smart pointers deemed ‘ok’?
  2. How else could I access persistant objects allocated on the heap other than a pointer?
  3. If I want a method that finds an item in the players inventory, but returns NULL if the item is not found, how else can that be implemented without pointers? Since the item returned from ‘findItem’ should be editable (to change the items count for instance), at the moment I return a pointer to the item in the vector. Is this a valid use of pointers?

Any help would be much appreciated!

  • 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-12T14:12:16+00:00Added an answer on June 12, 2026 at 2:12 pm
    1. Yes, raw, C-style pointers are considered bad. Smart pointers are OK. There are situations where you need to use (smart) pointers – collections of polymorphic objects for example: std::vector<std::unique_ptr<IObject> >.

    2. A persistent object doesn’t have to be on the heap. It can be an object with static storage duration or even an automatic object that lives just long enough – i.e. you create it in main().

    3. Numerous ways – you can throw an exception (probably too harsh) or go the std way an return an iterator – similar to .end().

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

Sidebar

Related Questions

I'm developing a game using cocos2d v2.0 beta2. Since i worked with iOS5.0 all
I'm developing a game with android using andengine. Basically, I'm using 2 ArrayList to
I am developing an app that reports a score to Game Center using the
Hi I am developing a game using libgdx framework, in that i am unable
I'm developing a game for iPhone using COCOS2D . In that, I need to
So I'm developing a game using Pygame and trying to abstract away a lot
We're developing a silverlight multiplayer game using TCP connections. We have all of our
I'm developing a game using JavaScript and canvas . As the game loads, all
I'm developing a game using libgdx in android. I dispose all the textures I
I'm developing a game using the libGDX Framework. I'd like to implement an icon

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.