Thread: Really Hope I'm not Overposting (Object passing)

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Absent Minded Programmer
    Join Date
    May 2005
    Posts
    968

    Really Hope I'm not Overposting (Object passing) (RESOLVED)

    So heres my World Class in .CPP Form

    Code:
    #include "World.h"
    
    std::vector<Object*> Scene_Objects;
    std::vector<Object*>::iterator Iter;
    
    
    void World::AddObjectToWorld()
    {
    	Scene_Objects.push_back(new Object);
    }
    
    void World::RemoveObjectFromWorld()
    {
    	for (Iter = Scene_Objects.begin(); Iter!=Scene_Objects.end();)
    {
        if ((*Iter)->MarkedForDeletion)
        {
            delete *Iter;
            Iter = Scene_Objects.erase(Iter);
        }
        else
        {
            ++Iter;
        }
    }
    
    };
    
    void World::RemoveAllObjectsFromWorld()
    {
    	for ( size_t i = 0; i < Scene_Objects.size( ); ++i )
    	{ 
    		delete Scene_Objects[i];
    		Scene_Objects.clear();
    	}
    };
    Just a couple functions to manage my Scene_Objects vector, (which will ultimately be sent to the render for final rendering)

    Here is my Object Class, its quite simple, but It needs something else, I'm quite sure of it...

    Code:
    #include "MS3D.h"
    
    #ifndef OBJECT_H
    #define OBJECT_H
    
    class Object
    {
    public:
    
    	bool MarkedForDeletion;
    
    	struct Location
    	{
    		float locx;
    		float locy;
    		float locz;
    	};
    
    };
    #endif
    And here is the final object (inherits the object class)

    Code:
    #ifndef C_CROSS_H
    #define C_CROSS_H
    
    
    #include "Object.h"
    
    class Cross : public Object
    {
    public:
    
    	MS3DModel *Model1;
    
    };
    
    #endif
    Now, back up there in the um, World class, I have an AddObjectToScene function, that creates a new object, is there any way I can set Cross = to Object, or do I have to switch a few parameters to make this work?
    Last edited by Shamino; 12-14-2005 at 08:35 PM.
    Sometimes I forget what I am doing when I enter a room, actually, quite often.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Passing an array of a class object into a function
    By maoqiu in forum C++ Programming
    Replies: 3
    Last Post: 10-25-2007, 08:42 AM
  2. Creating a database
    By Shamino in forum Game Programming
    Replies: 19
    Last Post: 06-10-2007, 01:09 PM
  3. Finding object code
    By kidburla in forum C Programming
    Replies: 3
    Last Post: 11-29-2005, 01:09 PM
  4. const at the end of a sub routine?
    By Kleid-0 in forum C++ Programming
    Replies: 14
    Last Post: 10-23-2005, 06:44 PM
  5. Object Arrays and Inheritance
    By AceHigh in forum C++ Programming
    Replies: 7
    Last Post: 07-28-2002, 04:08 AM