I am try to write a C++ program that tells the eldest and youngest sibling in a family. I am write this program declaring a class.I write all code program but my program does not compiles and give oprator error. Please someone check this and make it correct.I need this type of output
Please enter the particulars of each sibling:
Please enter the particulars of Sibling: 1
Name: Arif Age: 20
Please enter the particulars of Sibling: 2
Name: Sana Age: 16
Please enter the particulars of Sibling: 3
Name: Sobia Age: 13
Please enter the particulars of Sibling: 4
Name: Amna Age: 10
My rogram source code is here

#include <iostream.h>
#include <string.h>
#include <conio.h>

// defining the Sibling class
class Sibling
{
    // hidden part of the class
    private:
        char *name;    // for Sibling name
        int age;       // for Sibling age
     // interface of the class
     public:
        Sibling(); //constructor
        Sibling(const Sibling &obj);//copy constructor
        void setname(char *);//setter function for name
        void setage(int a);  //setter function for age
        char *getname(); //getter function for name
        int getage();    //getter function for age  
        ~Sibling();         //destructor
        bool operator >(int *array int arraysize);                        // overloading assignment operator
};
bool Sibling::operator >( int *array, int arraysize)
{
    for(int i=0;i<arraysize;i++)
    if a[i]>a[i+1];
    {
    int *temp=a[i];
    a[i]=a[i+1];
    a[i+1]=*temp;
    }
}
Sibling::~Sibling()//destructor
{
    if (name)
    {
    delete[]name;
    }
}

Sibling::Sibling(const Sibling &obj)
{
    int len=strlen(obj.name);
    name=new char(len+1);
    strcpy(name,obj.name);
    age=obj.age;
}
// setting the Sibling name
void Sibling::setname(char *SiblingName)
{
    name= new char(strlen(SiblingName+1));
    strcpy(name,SiblingName);
}
// setting the Sibling age
void Sibling::setage(int SiblingAge)
{
    if (age<=0)
    {
    cout<<"Negative age is not allowed";
    age=0;
    }
    age=SiblingAge;
}
// getting the Sibling name
char *Sibling ::getname()
{
    return name;
}
// getting the Sibling age
int Sibling:: getage()
{
    return age;
}

//Main program. We will take  Sibling object  

int main()
{
    int a=0 ;
    char *nameofsibling=NULL;
    int ageofsibling=0;
    cout<<"Plz enter the number of Sibling";
    cin>>a;
    Sibling siblingobj[a];

    for(a=1;a<=a;a++)
    {
        cout<<"plz enter the particular of Sibling"<<a<<endl;
        cout<<"Name: ";
        cin>>nameofsibling;
        cout<<"Age: ";
        cin>>ageofsibling;
        siblingobj[a].setname(nameofsibling);
        siblingobj[a].setage(ageofsibling);
    }

    return 0;
    getch();
}
This article has been dead for over six months. Start a new discussion instead.