Sponsored Links


Results 1 to 2 of 2

Thread: A partial specialization may inherit from a complete specialization? Actually I did n

  1. #1
    Senior Member saneha's Avatar
    Join Date
    Apr 2011
    Posts
    266

    Arrow A partial specialization may inherit from a complete specialization? Actually I did n

    Sponsored Links1


    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

    Sponsored Links

    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..

  2. #2
    Administrator Vuhelper's Avatar
    Join Date
    Apr 2011
    Posts
    9,578
    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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 10-14-2014, 09:37 PM
  2. Replies: 0
    Last Post: 12-26-2012, 04:06 PM
  3. CS-201 5th assignment complete solution
    By gm mughal in forum Mcs
    Replies: 2
    Last Post: 06-30-2011, 09:44 PM
  4. Replies: 0
    Last Post: 05-02-2011, 06:39 PM
  5. AMD COMPLETE PC !! for sale in pakistan
    By vustudents in forum Virtual University Laptops
    Replies: 0
    Last Post: 10-30-2010, 12:16 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
-: Vuhelp Disclaimer :-
None of the files shown here are hosted or transmitted by this server. The links are provided solely by this site's users. The administrator's or staff of Vuhelp.net cannot be held responsible for what its users post, or any other actions of its users. You may not use this site to distribute or download any material when you do not have the legal rights to do so. It is your own responsibility to adhere to these terms. If you have any doubts about legality of content or you have any suspicions, feel free to contact us.
Online Education | JhelumSoft | Jobs