Confusion
Posted: Fri Jan 21, 2011 8:53 pm
Well lately I have been developing a game engine that contains the following class.
The way I have used this function "CreateInstance" is the following...
If I create five "fedships" in the std::vector "fedships" this is my console output
(Hoping the messages are relatively understandable).
I have noticed every frame that "fedships" subtracts a "fedship" (35 on the first frame :/) but yet all instances of "fedship" remain functional and :/ Also I cannot modify "fedships" for example the "SetPosition" function that is up there does not work .
I am getting the feeling that std::vectors are not the way to go for this and I was wondering if there was another type of container or something that would be like a std::vector but with no memory heap allocation? Also I was wondering (although not expecting) if anyone can understand the reason for this behavior in my program?
P.s I know I sometimes have a hard time getting my point across if anyone needs any clarification I will do my best to provide it.
P.s.s Sorry for making 2 posts in 1 week
P.s.s.s Yes I know this is probably the most n00by pice of code your eyes have ever had to bear whitness to.
EDIT:
Also noticed after this post that another indicator in my log says that "fedships" is of the correct size 5.
Code: Select all
class MiscFucntions
{
public:
class InstanceCreate
{
public:
typedef class Instance;
typedef std::vetcor<Instance> Vetcor;
template<class Instance>
Instance CreateInstance(Instance A)
{
return A;
}
};
class InstanceDestroy
{
public:
//Not done!!//
typedef class InstanceToDestroy;
template<class InstanceToDestroy>
InstanceToDestroy DestroyInstance(InstanceToDestroy ClassInstanceToDestroy)
{
}
};
};
Code: Select all
//"fedship" is a class an "fedships" is a std::vetcor.//
MiscFucntions::InstanceCreate V;
fedship A;
fedship B;
*fwrexp = 300;
*fwreyp = 300;
fedships.push_back(V.CreateInstance(A));
*fwreyp += 100;
fedships[0] = B.SetPosition(*fwrexp, *fwreyp, fedships[0]);
fedships.push_back(V.CreateInstance(A));
//etc...///
I have noticed every frame that "fedships" subtracts a "fedship" (35 on the first frame :/) but yet all instances of "fedship" remain functional and :/ Also I cannot modify "fedships" for example the "SetPosition" function that is up there does not work .
I am getting the feeling that std::vectors are not the way to go for this and I was wondering if there was another type of container or something that would be like a std::vector but with no memory heap allocation? Also I was wondering (although not expecting) if anyone can understand the reason for this behavior in my program?
P.s I know I sometimes have a hard time getting my point across if anyone needs any clarification I will do my best to provide it.
P.s.s Sorry for making 2 posts in 1 week
P.s.s.s Yes I know this is probably the most n00by pice of code your eyes have ever had to bear whitness to.
EDIT:
Also noticed after this post that another indicator in my log says that "fedships" is of the correct size 5.