Hey everyone. I have a function, Add, in my class, VQueue, which is templated.
Add takes one parameter: The address of a variable of the class's type.Code:VQueue<MyStruct> MyQ;
But when I make VQueue of type int...Code:template<class Type> void VQueue<Type>::Add( Type& Addition ) { ... }
[code]
VQueue<int> MyOtherQ;
[code]
and pass 5 to Add...
it says that there is no function that accepts type int. Well I understand that part, because it's an integer, and not the address of an integer. This would work fine:Code:MyOtherQ.Add( 5 );
But I want to be able to just use 5 instead of making it another variable. I can't make Add accept the Type by value, because that would mean passing large structures by value.Code:int Moo = 5; MyOtherQ.Add( Moo );
So I had this crazy idea, "What if I use passing a reference for all the types except the simple ones (int, char, bool, int*, etc.)?"
How do I do this? I have no idea where to start. Or can someone give me a few keywords to search for? I tried "templated classes c++ exceptions" but all it gave me was try-throw-catch junk.
Thanks!
Thanks!



LinkBack URL
About LinkBacks


