Sponsored Links


Results 1 to 2 of 2

Thread: What is virtual inheritance,generic algorithmswith,member temples

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

    Icon20 What is virtual inheritance,generic algorithmswith,member temples

    Sponsored Links1



  2. #2
    Administrator Vuhelper's Avatar
    Join Date
    Apr 2011
    Posts
    9,578
    Virtual inheritance is a type of inheritance in which the part of the object that belongs to virtual base class becomes common direct base class for derived class and any other class that derives from it. Virtual inheritance is used in multiple inheritance.
    Virtual inheritance example in c++:
    class Animal{
    public:
    virtual void eat();
    };
    // Two classes virtually inheriting Animal:
    class Mammal : public virtual Animal {
    public:
    virtual void walk();
    };
    class WingedAnimal : public virtual Animal {
    public:
    virtual void flap();
    };
    // A bat is a winged mammal
    class Bat : public Mammal, public WingedAnimal
    {
    };
    Generic algorithms are those algorithms that are independent of data structures. This can be achieved using Generic Programming in which a function works for all types of containers.
    Example:
    template void Swap(T & a, T & b) //"&" passes parameters by reference
    {
    T temp = b;
    b = a;
    a = temp;
    }
    string hello = "world!", world = "Hello, ";
    Swap( world, hello );
    cout << hello << world << endl;
    //Output is "Hello, world!"

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. protected inheritance and abstract classes in C++ 2012
    By Vuhelper in forum C++ Programing
    Replies: 0
    Last Post: 01-14-2012, 05:48 PM
  2. i am a new member of this site so plz help me
    By kamran ahmed in forum MBA
    Replies: 4
    Last Post: 10-27-2011, 04:35 AM
  3. Replies: 1
    Last Post: 05-02-2011, 04:57 PM
  4. Replies: 1
    Last Post: 05-02-2011, 04:50 PM
  5. Slam to all Member
    By karlu in forum Member's Introduction
    Replies: 3
    Last Post: 03-30-2011, 04:03 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