Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualMichael Tanczos

Posted 29 December 2012 - 12:40 AM

>.<
I know why it gave me the * Error operator, I kinda failed to read correct (Was in a Hurry for my driving lesson) either way. tEntity is now a proper pointer and not a instance of Entity.

But May I ask
is this the correct way to insert something into a vector while am here I may aswell ask, instead of the * operator error I now get a error/warning on my template factory.
And the reason why I use template instead of pre defined classes is that I hope one day I will be good enough to make it more "dynamic" or more automatic instead of needing me to make a new factory for each new class.

std::vector vEntity;std::vector::iterator vEntityEnd;
int vEntityMax = 10;Entity* tEntity;
EntityFactory eFactory;
int vEntitySize = 0;
vEntitySize = vEntity.size();
vEntityEnd = vEntity.end();
if(vEntitySize < vEntityMax)
{
//MessageBox(0,"Lets hope this work","Entity have NOT Increased by 1 yet!",MB_OK); 
tEntity = eFactory.EntityInstantiate<Entity>();
vEntity.insert(vEntityEnd,tEntity);
MessageBox(0,"Screw This","Entity Increased by 1!",MB_OK);	
}


Edit:
Here's the error

 

 
</p><div>   Reason: cannot convert from 'Entity *' to 'const Entity'</div>
<div>1>          No constructor could take the source type, or constructor overload resolution was ambiguous</div>
<div>1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\xmemory(280) : see reference to function template instantiation 'void std::allocator<_Ty>::construct<Entity*&>(Entity *,_Other)' being compiled</div>
<div>1>          with</div>
<div>1>          [</div>
<div>1>              _Ty=Entity,</div>
<div>1>              _Other=Entity *&</div>
<div>1>          ]</div>
<div>1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\vector(668) : see reference to function template instantiation 'void std::_Cons_val<std::allocator<_Ty>,Entity,Entity*&>(_Alloc &,_Ty1 *,_Ty2)' being compiled</div>
<div>1>          with</div>
<div>1>          [</div>
<div>1>              _Ty=Entity,</div>
<div>1>              _Alloc=std::allocator<Entity>,</div>
<div>1>              _Ty1=Entity,</div>
<div>1>              _Ty2=Entity *&</div>
<div>1>          ]</div>
<div>1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\vector(688) : see reference to function template instantiation 'void std::vector<_Ty>::emplace_back<Entity*&>(_Valty)' being compiled</div>
<div>1>          with</div>
<div>1>          [</div>
<div>1>              _Ty=Entity,</div>
<div>1>              _Valty=Entity *&</div>
<div>1>          ]</div>
<div>1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\vector(675) : see reference to function template instantiation 'std::_Vector_iterator<_Myvec> std::vector<_Ty>::emplace<Entity*&>(std::_Vector_const_iterator<_Myvec>,_Valty)' being compiled</div>
<div>1>          with</div>
<div>1>          [</div>
<div>1>              _Myvec=std::_Vector_val<Entity,std::allocator<Entity>>,</div>
<div>1>              _Ty=Entity,</div>
<div>1>              _Valty=Entity *&</div>
<div>1>          ]</div>
<div>1>          c:\users\conny.conny-dator\desktop\fusionempty\fusionempty\windowshandler.cpp(223) : see reference to function template instantiation 'std::_Vector_iterator<_Myvec> std::vector<_Ty>::insert<Entity*&>(std::_Vector_const_iterator<_Myvec>,_Valty)' being compiled</div>
<div>1>          with</div>
<div>1>          [</div>
<div>1>              _Myvec=std::_Vector_val<Entity,std::allocator<Entity>>,</div>
<div>1>              _Ty=Entity,</div>
<div>1>              _Valty=Entity *&</div>
<div>1>          ]</div>
<div>
 

#3Conny14156

Posted 28 December 2012 - 06:26 AM

>.<
I know why it gave me the * Error operator, I kinda failed to read correct (Was in a Hurry for my driving lesson) either way. tEntity is now a proper pointer and not a instance of Entity.

But May I ask
is this the correct way to insert something into a vector while am here I may aswell ask, instead of the * operator error I now get a error/warning on my template factory.
And the reason why I use template instead of pre defined classes is that I hope one day I will be good enough to make it more "dynamic" or more automatic instead of needing me to make a new factory for each new class.

std::vector vEntity;std::vector::iterator vEntityEnd;
int vEntityMax = 10;Entity* tEntity;
EntityFactory eFactory;
int vEntitySize = 0;
vEntitySize = vEntity.size();
vEntityEnd = vEntity.end();
if(vEntitySize < vEntityMax)
{
//MessageBox(0,"Lets hope this work","Entity have NOT Increased by 1 yet!",MB_OK); 
tEntity = eFactory.EntityInstantiate<Entity>();
vEntity.insert(vEntityEnd,tEntity);
MessageBox(0,"Screw This","Entity Increased by 1!",MB_OK);	
}


Edit:
Here's the error


   Reason: cannot convert from 'Entity *' to 'const Entity'
1>          No constructor could take the source type, or constructor overload resolution was ambiguous
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\xmemory(280) : see reference to function template instantiation 'void std::allocator<_Ty>::construct<Entity*&>(Entity *,_Other)' being compiled
1>          with
1>          [
1>              _Ty=Entity,
1>              _Other=Entity *&
1>          ]
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\vector(668) : see reference to function template instantiation 'void std::_Cons_val<std::allocator<_Ty>,Entity,Entity*&>(_Alloc &,_Ty1 *,_Ty2)' being compiled
1>          with
1>          [
1>              _Ty=Entity,
1>              _Alloc=std::allocator<Entity>,
1>              _Ty1=Entity,
1>              _Ty2=Entity *&
1>          ]
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\vector(688) : see reference to function template instantiation 'void std::vector<_Ty>::emplace_back<Entity*&>(_Valty)' being compiled
1>          with
1>          [
1>              _Ty=Entity,
1>              _Valty=Entity *&
1>          ]
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\vector(675) : see reference to function template instantiation 'std::_Vector_iterator<_Myvec> std::vector<_Ty>::emplace<Entity*&>(std::_Vector_const_iterator<_Myvec>,_Valty)' being compiled
1>          with
1>          [
1>              _Myvec=std::_Vector_val<Entity,std::allocator<Entity>>,
1>              _Ty=Entity,
1>              _Valty=Entity *&
1>          ]
1>          c:\users\conny.conny-dator\desktop\fusionempty\fusionempty\windowshandler.cpp(223) : see reference to function template instantiation 'std::_Vector_iterator<_Myvec> std::vector<_Ty>::insert<Entity*&>(std::_Vector_const_iterator<_Myvec>,_Valty)' being compiled
1>          with
1>          [
1>              _Myvec=std::_Vector_val<Entity,std::allocator<Entity>>,
1>              _Ty=Entity,
1>              _Valty=Entity *&
1>          ]

#2Conny14156

Posted 28 December 2012 - 06:25 AM

>.<
I know why it gave me the * Error operator, I kinda failed to read correct (Was in a Hurry for my driving lesson) either way. tEntity is now a proper pointer and not a instance of Entity.

But May I ask
is this the correct way to insert something into a vector while am here I may aswell ask, instead of the * operator error I now get a error/warning on my template factory.
And the reason why I use template instead of pre defined classes is that I hope one day I will be good enough to make it more "dynamic" or more automatic instead of needing me to make a new factory for each new class.

std::vector vEntity;
std::vector::iterator vEntityEnd;
int vEntityMax = 10;
Entity* tEntity;
EntityFactory eFactory;
int vEntitySize = 0;
vEntitySize = vEntity.size();	
vEntityEnd = vEntity.end();	
if(vEntitySize < vEntityMax)	
{		
//MessageBox(0,"Lets hope this work","Entity have NOT Increased by 1 yet!",MB_OK); 		
tEntity = eFactory.EntityInstantiate();		
vEntity.insert(vEntityEnd,tEntity);	
MessageBox(0,"Screw This","Entity Increased by 1!",MB_OK);
	}

 


Edit:

Here's the error 

   Reason: cannot convert from 'Entity *' to 'const Entity'
1>          No constructor could take the source type, or constructor overload resolution was ambiguous
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\xmemory(280) : see reference to function template instantiation 'void std::allocator<_Ty>::construct<Entity*&>(Entity *,_Other)' being compiled
1>          with
1>          [
1>              _Ty=Entity,
1>              _Other=Entity *&
1>          ]
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\vector(668) : see reference to function template instantiation 'void std::_Cons_val<std::allocator<_Ty>,Entity,Entity*&>(_Alloc &,_Ty1 *,_Ty2)' being compiled
1>          with
1>          [
1>              _Ty=Entity,
1>              _Alloc=std::allocator<Entity>,
1>              _Ty1=Entity,
1>              _Ty2=Entity *&
1>          ]
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\vector(688) : see reference to function template instantiation 'void std::vector<_Ty>::emplace_back<Entity*&>(_Valty)' being compiled
1>          with
1>          [
1>              _Ty=Entity,
1>              _Valty=Entity *&
1>          ]
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\vector(675) : see reference to function template instantiation 'std::_Vector_iterator<_Myvec> std::vector<_Ty>::emplace<Entity*&>(std::_Vector_const_iterator<_Myvec>,_Valty)' being compiled
1>          with
1>          [
1>              _Myvec=std::_Vector_val<Entity,std::allocator<Entity>>,
1>              _Ty=Entity,
1>              _Valty=Entity *&
1>          ]
1>          c:\users\conny.conny-dator\desktop\fusionempty\fusionempty\windowshandler.cpp(223) : see reference to function template instantiation 'std::_Vector_iterator<_Myvec> std::vector<_Ty>::insert<Entity*&>(std::_Vector_const_iterator<_Myvec>,_Valty)' being compiled
1>          with
1>          [
1>              _Myvec=std::_Vector_val<Entity,std::allocator<Entity>>,
1>              _Ty=Entity,
1>              _Valty=Entity *&
1>          ]

 

 


 


#1Conny14156

Posted 28 December 2012 - 06:20 AM

>.<

I know why it gave me the * Error operator, I kinda failed to read correct (Was in a Hurry for my driving lesson) either way. tEntity is now a proper pointer and not a instance of Entity. 

 

But May I ask 

is this the correct way to insert something into a vector while am here I may aswell ask, instead of the * operator error I now get a error/warning on my template factory.

And the reason why I use template instead of pre defined classes is that I hope one day I will be good enough to make it more "dynamic" or more automatic instead of needing me to make a new factory for each new class.

	
std::vector<Entity> vEntity;
std::vector<Entity>::iterator vEntityEnd;
int vEntityMax = 10;
Entity* tEntity;
EntityFactory eFactory;
int vEntitySize = 0;




vEntitySize = vEntity.size();
	vEntityEnd = vEntity.end();
	if(vEntitySize < vEntityMax)
	{
		//MessageBox(0,"Lets hope this work","Entity have NOT Increased by 1 yet!",MB_OK);
 		tEntity = eFactory.EntityInstantiate<Entity>();
		vEntity.insert(vEntityEnd,tEntity);
		MessageBox(0,"Screw This","Entity Increased by 1!",MB_OK);
	}

PARTNERS