can anyone solve this problem for me ???
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#include<iostream>
#include<string>
#define size 10

using namespace std;

struct student {
string name;
int id;
string prog;
double cgpa;
};


class stinfo {
    private:
        student data[size];
        int last;
    public:
        stinfo();
        void add(string name, int id, string prog, double cgpa);


};

stinfo :: stinfo()
{
    last = 0 ;
}


void stinfo::add(string name, int id,string prog, double cgpa)
{
    if (last == data[size]) {
    return ;
}
data[last].name = name;
data[last].id = id;
data[last].prog = prog;
data[last].cgpa = cgpa;
++last;
}



int main()
{
    char ans;
    string name1,prog1;
    int id1;
    double cgpa1;

    stinfo st;

    cout <<endl;
        cout <<">>>>> INSERT NEW STUDENT INFORMATION <<<<<"<<endl;

        cout <<"NAME : ";
        cin >>name1;

        cout <<"ID: ";
        cin >>id1;

        cout <<"PROGRAMME : ";
        cin >>prog1;

        cout <<"CGPA: ";
        cin >>cgpa1;

        st.add ( name1,id1,prog1,cgpa1 );

        system("pause");
    return 0;


}

`

can anyone solve this problem for me ???

We're not here to solve your homework, we're here to help you figure out how YOU can solve it.

Class Array

vaguely defined situation, what should we look for?

 if (last == data[size])

presumably should be

 if (last == size)

because you want to see if you've reached your end of the array.
And as a programming concept, macros are in upper-case letters, so:

#define size 10

would be

#define SIZE 10
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.