Start New Discussion within our Software Development Community

can anyone solve this problem for me ???

#define size 10

using namespace std;

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

class stinfo {
        student data[size];
        int last;
        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;

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 );

    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
This article has been dead for over six months. Start a new discussion instead.