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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:15:08+00:00 2026-06-17T11:15:08+00:00

Alright, here I have this small example of my complex class class LivingObject {

  • 0

Alright, here I have this small example of my complex class

class LivingObject
{
 Ogre::SceneNode* myNode;
 Gorilla::ScreenRenderable* myScrRend;
 Gorilla::Layer* myRendLayer;
 Gorilla::Rectangle* myRendRect;
 int Health,Energy,Strength,Dexterity,Intelligence;
 float Speed,posX,posY,posZ;
 //Assortment of functions
};//Note: Specific members and functions are public/private, but is not relevant

Here is some game class info

class myGame
{
 Ogre::Viewport* myViewport;//random
 LivingObject LiveObjectArray[100]//question 1: holds the array of objects from a parsed file
 std::vector<std::tr1::shared_ptr<LivingObject> > spawnList;//question 2
};

1) How should I be declaring LivingObject where I can copy it later(the current method I am using gives an error: conversion from 'LivingObject*' to non-scalar type 'LivingObject' requested)LivingObject TestObj=new LivingObject;

1a) What do I do with pointers like LivingObject::myNode when making a new object, should I make them objects? or is something else wrong?(Note: I am using Ogre3D and this is the way that the tutorials made me set everything…)

2) When the above is solved, how would I then put it into a shared_ptr vector and access that specific element for functions(e.g. spawnList[15].(or ->)Attack(target);

  • 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-17T11:15:09+00:00Added an answer on June 17, 2026 at 11:15 am

    1) In order to copy an object, use this code:

    string s;
    string t = s;
    

    1a) What do those pointers represent? If they represent exclusive ownership, you must copy the objects they point to when copying the owning object. Check any good text’s introduction to constructors and destructors. Consider making the LivingObject class non-copyable.

    2) Try this:

    shared_ptr<T> p(new T);
    vector<T> v;
    v.push_back(p);
    ...
    shared_ptr<T> q = v[0];
    q->member_function();
    

    As a last advise, you need a good C++ book. Another great resource is an online community of other users like this one here. If possible, try to reduce your code though. It’s enough that LivingObject has one example pointer. Good luck!

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

Sidebar

Related Questions

alright so i have a small problem here, i have this here. - (void)alertView:(UIAlertView
Alright so here is the question. I have a user class which contains a
Alright here is the thing, I have this site that was once wordpress but
I have written this piece of code here and I have linked it alright
Alright so I have this C++ image capturing class. I was wondering if I
Alright so I'm trying to get captcha to work here and I have this
I'm having a little predicament switching between views, here. Alright, so, I have this
Alright...I am here looking for some bread crumbs. This is my code: using System;
Alright I don't see why this isnt working. It seems pretty simple. Here is
Alright, hard to phrase an exact title for this question, but here goes... I

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.