Multi-Level inheritances C++ program to print hollow rhombus, parallelogram star pattern

Develop a C++ program to print a hollow rhombus star series pattern using for loop and Multi-Level Inheritance.
How to print hollow rhombus or parallelogram star pattern in C++ programming using Multi-Level Inheritance in OOP. The Logic to print empty rhombus or parallelogram star pattern series in C++ programming using Multi-Level Inheritance.

#include<iostream>
using namespace std;
class A 
{
	public:
		int r;
};
class B:public A
{
	protected:
	 int sp;
};      
class C:public B
{
	public:
	void disp()
	{
	for(r=1;r<=4;r++)  //loop for displaying the number of rows
	{
		for(sp=r;sp<4;sp++) //loop for printing the spaces in first row
		{
			cout<<" ";
		}
		if(r==1||r==4) //condition for first or last row
		{
			for(sp=1;sp<=4;sp++) //loop for printing stars in first and last row if above condition is true
			{
				cout<<"*";
			}
		}
		else //print firstly 1 star then 2 spaces and then one star if "if condition" is false
		{
			cout<<"*";
			for(sp=1;sp<=2;sp++)
			{
				cout<<" ";
			}
			cout<<"*";
		}
	    cout<<endl;
		
	}
	
   }	
};
    int main()
    {
    C t4tutorials; //create the object of class
    t4tutorials.disp(); // call function by object
    }

Output

 

Prof.Fazal Rehman Shamil (Available for Professional Discussions)
1. Message on Facebook page for discussions,
2. Video lectures on Youtube
3. Email is only for Advertisement/business enquiries.