Tuesday, 3 April 2012

()Operator example on Template


 #include <iostream>
 template <class I>
 class B
 {
 public:
   static B b;
  I data;
I operator()()
{
data=10;
return data;
}
static B& instance()
{
return b;
}
};

template<class T>
B<T> B<T>::b;
template class B<int>;
typedef B<int> type;

 int main()
 {
   std::cout << type::b()<< std::endl; // 0
   return 0;
 }

No comments:

Post a Comment

AWS Data Pipeline Services

https://www.youtube.com/watch?v=tykcCf-Zz1M