Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A partial specialization may inherit from a complete specialization? Actually I did n
#1
A partial specialization may inherit from a complete specialization? Actually I did not understand from your lecture and also tell the reason that why it may inherit from complete specialization

A class template may inherit from an ordinary class.? Please explain this

A partial specialization may inherit from an ordinary class. Actually ordinary class has not template type parameter etc..
Reply
#2
A partial specialization may inherit from a complete specialization:
template<class T>
class B<T*> : public A<float *>
{ … };
int main() {
A obj1;
B obj2;
return 0;
}
obj2 type is int* .class B which is a derived class is instantiated for int * type, where its base class is a specialized class (for float*). You can call inherited methods of base class in template class irrespective of the type of the object for which this template class is instantiated. In this case either class B is instantiated for int or for char, it does not matter, but remember that you can call the public and protected methods / members of base class in template class.
A class template may inherit from an ordinary class:

class A {…};
template<class T> class B: public A {…};
int main(){
A obj1;
B obj2;
return 0;
}
obj2 type is B int. class B which is a derived class is instantiated for int type, where its base class is an ordinary class. You can call inherited methods of base class in template class irrespective of the type of the object for which this template class is instantiated. In this case either class B is instantiated for int or for char, it does not matter, but remember that you can call the public and protected methods / members of base class in template class.

A partial specialization may inherit from an ordinary class:
template<class T> class B<T *> : public A { … };
int main() {
A obj1;
B obj2;
return 0;
}
obj2 type is B int*. Class B which is a derived class is instantiated for int* type, where its base class is an ordinary class. You can call inherited methods of base class in template class irrespective of the type of the object for which this template class is instantiated. In this case either class B is instantiated for int or for char, it does not matter, but remember that you can call the public and protected methods / members of base class in template class.

0300-9520262
Get solution in 24 hour
|cpmputer & internetConfusedmileys81:[SIZE="4"][SIZE="3"]....[/SIZE][/SIZE]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  What is difference among Binary Tree, Complete Binary Tree and Binary Search Tree? Vuhelper 2 4,347 03-18-2012, 12:47 AM
Last Post: Xpert
  What is difference between a complete binary tree and strictly binary tree? Vuhelper 0 4,486 11-05-2011, 05:24 PM
Last Post: Vuhelper
  A partial specialization may inherit from an ordinary class saneha 0 2,028 05-02-2011, 06:39 PM
Last Post: saneha
  assalam o alaikum sir Is that neccessory to use a Function to complete this assignmen sana.pari 1 1,915 04-24-2011, 06:14 PM
Last Post: Support

Forum Jump:


Users browsing this thread: 1 Guest(s)