Develop a C++ program to print hollow square or rectangle star pattern by using the virtual base class in Object Oriented Programming.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
#include<iostream> using namespace std; class a { public: int n; }; class b: virtual public a { public: int i; }; class c:virtual public a { public: int j; }; class d:public b,c { public: int show_T4Tutorials() { cout<<"enter number"; cin>>n; for(i=1;i<=n;i++) { for( j=1;j<=n;j++) { if(i==1||i==n||j==1||j==n) { cout<<"*"; } else { cout<<" "; } } cout<<endl; } } }; int main() { d obj; obj. show_T4Tutorials (); } |
Output

Write a C++ program to print hollow square or rectangle star pattern by using for loop and multiple inheritance with virtual class in OOP.