Hi  The struct that u are using is basically a templated struct and when u are 
calling static function you have to mention the template arguments.But why?
  Actually when we are using  templates there is no such thing as sum<T>.all 
these templates change to the required classes (that were used in the code) and 
only that generated classes are then added to the obj file.the error free code 
looks like
   
   #include <iostream>
#include <conio.h>
using namespace std;
template <class T> void foo(T op1, T op2) {
std::cout << "op1 = " << op1 << std::endl;
std::cout << "op2 = " << op2 << std::endl; 
}
template <class T> 
struct sum {
static void foo(T op1, T op2)
{
std::cout << "sum = " << op2 << std::endl;
}
};
  int main() 
{ 
foo(1,3);
foo<int>(1,' 3');
sum<int>::foo(1,2) ; // Error in this line and corrected through providing 
argument for call
  getch();
return 0; 
} 


praveen kumar <[EMAIL PROTECTED]> wrote:          hai
when iam executing the following code
there is a compiler error showing in the line mentioned below (bolded line)
the error is `template<class T> struct sum' used without template parameters 
what exactly is this and how can i sort this
please help me
praveen

#include <iostream>
#include <conio.h>
using namespace std;
template <class T> void foo(T op1, T op2) {
std::cout << "op1 = " << op1 << std::endl;
std::cout << "op2 = " << op2 << std::endl; 
}
template <class T> 
struct sum {
static void foo(T op1, T op2)
{
std::cout << "sum = " << op2 << std::endl;
}
};

int main() 
{ 
foo(1,3);
foo<int>(1,'3');
sum::foo(1,2); // Error in this line

getch();
return 0; 
} 

---------------------------------
>From Chandigarh to Chennai - find friends all over India. Click here.

[Non-text portions of this message have been removed]



                           


Regards,
  Umar Waqas
   

 __________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

[Non-text portions of this message have been removed]

Reply via email to