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

What is a superconductor?

 A superconductor is a material that can conduct electricity with zero electrical resistance when it is cooled below a specific, very cold t...