Sunday, February 25, 2018

C++ program : Template Function

#include<iostream>
using namespace std;
class Person {
    public: Person(int x) { cout << x << ":"; }
        Person() {}
};
class Instructor : virtual public Person {
    public: Instructor(int x) :Person(x) { }
};
class Student : virtual public Person {
    public: Student(int x) :Person(x) { }
};
class TA :  public Instructor,  public Student {
    public: TA(int x) :Student(x), Instructor(x) { cout << x * 3 ; }
};
int main() {
    int no;
    cin >> no;
    TA ta(no);
    return 0;
}

Thanks
Happy Computing !

No comments:

Post a Comment

Sacred Thought

26 April 2024  Dear friends, I write the explanation of two verses of Geets for all of you, I hope you all will like it and benefit from it....