Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- interface IFoo
- {
- }
- class Foo<T> where T : IFoo
- {
- }
- class Bar : IFoo
- {
- }
- class Simpson
- {
- }
- class Program
- {
- static void Main(string[] args)
- {
- Foo<Bar> a = new Foo<Bar>();
- Foo<Simpson> b = new Foo<Simpson>(); // error CS0309
- }
- }
- class IFoo
- {
- public:
- typedef int IsDerivedFromIFoo;
- };
- template <typename T>
- class Foo<T>
- {
- typedef typename T::IsDerivedFromIFoo IFooGuard;
- }
- template <class T>
- int compute_length(T *value)
- {
- return value->length();
- }
- string s = "test";
- vector<int> vec;
- int i = 0;
- compute_length(&s);
- compute_length(&vec);
- compute_length(&i);
- template<class t> class FOO { private: FOO(){}};
- template<> class FOO<int>{public: FOO(){}};
- template<> class FOO<float>{public: FOO(){}};
Add Comment
Please, Sign In to add comment