Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

template help? how to instantiate??

Status
Not open for further replies.

haukero

Technical User
Nov 26, 2001
5
DE

hello,

i have a simple 'point'-template class with 2 parameter standard constructor! i wanna instantiate like this :

point<unsigned int> myPoint (x = 0, y = 0);

the compiler (vc++ 6 sp5) thinks 'myPoint' is a function with 2 parameters returning point<unsigned int> instead of a point instance!! ;(

so what can i do to tell the compiler it's an instance and no function! please help!!

thanks a lot,
haukero
 
whoops i posted the wrong instantiation code, hehe the one i posted won't work of course! so here's the correct one :

point <int> myPoint (int x, int y);

as already said the compiler treats this instantiation as function prototype and not as instantiation!! ;(

myPoint is an attribute of another template with x and y as parameters so they're already declared and defined when calling the instantiation of myPoint!

i hope someone can help me!

thanks in advance,
haukero
 
By specifying parameter types
point <int> myPoint (int x, int y);
It looks very much like a declaration. Should you not be doing something like
point <int> myPoint (1, 2);
or
point <int> myPoint (x, y);

???
If this isn't the problem then mayby if you give an example of the point class declaration and a snip of code where you create and use instance i may be able to help.

EMail: lgworks at uklinux.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top