Monday, March 14, 2022

DYNAMIC OBJECT ARRAY

 #include <iostream>

using namespace std;
#include <conio.h>
class stde
{
    int rnumber;
    string name;

public:
    stde(){};
    stde(int rnumber, string name)
    {
        this->rnumber = rnumber;
        this->name = name;
    }
    void printdata()
    {

        cout << "rollnumber : " << rnumber << endl;
        cout << "name : " << name << endl;
    }
};
void getdata(stde *argu, int size)
{
    int rnumber;
    string name;
    for (int i = 0; i < size; i++)
    {
        cout << "for student number " << i + 1 << endl
             << endl;

        cout << "enter rollnumber: " << endl;
        cin >> rnumber;
        cout << "enter name: ";
        cin >> name;
        *(argu + i) = stde(rnumber, name);
    }
}
int main()
{
    int size;
    cout << "enter number of students \n"
         << endl;

    cin >> size;
    system("cls");
    stde *sptr = new stde[size];
    getdata(sptr, size);
    system("cls");
    for (int i = 0; i < size; i++)
    {
        cout << "for student number " << i + 1 << " details entered were" << endl
             << endl;
        (sptr + i)->printdata();
    }

    return 0;
}
REFRENCE LINK

No comments:

Software scope

 In software engineering, the software scope refers to the boundaries and limitations of a software project. It defines what the software wi...

Popular Posts