p_o_x
June 2nd, 2008, 07:35 AM
i want to initialize a pointer to a template, but as a java/c# programmer the syntax is throwing me off. i want to be able to write the following in one line of code:
Key<int> k(&otherVariable);
Key<int>* j = &k;
//Key is my designed template
this works, but i'd like to avoid explicitly creating an object just to get a pointer to it. looking for the c++ equivalent of java's:
Key<int> k = new Key<int>(otherVariable);
//where the other variable is already a reference
//k will now point to a Key<int> object
thoughts?
ps, not a professional programmer, if i've missed something here, feel free to explain :)
Key<int> k(&otherVariable);
Key<int>* j = &k;
//Key is my designed template
this works, but i'd like to avoid explicitly creating an object just to get a pointer to it. looking for the c++ equivalent of java's:
Key<int> k = new Key<int>(otherVariable);
//where the other variable is already a reference
//k will now point to a Key<int> object
thoughts?
ps, not a professional programmer, if i've missed something here, feel free to explain :)