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

How can I run a C++ program directly from Windows?

How-can-I-run-a-C-program-directly-from-Windows