Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

array of objects in class c++

#include <iostream>
using namespace std;
struct stud
{
    public:
    int rno;
    void getroll()
    {
        cout<<"
Enter roll:";
        cin>>rno;
    }
    void printroll()
    {
        cout<<"
roll:";
        cout<<rno;
    }
};
int main()
{
    stud s[5];
    for(int i=0;i<5;i++)
    {
        s[i].getroll();
    }
    s[2].printroll();
    return 0;
}
 
PREVIOUS NEXT
Tagged: #array #objects #class
ADD COMMENT
Topic
Name
3+4 =