CLASSES WITH CONSTANT DATA MEMBERS

SOURCE CODE:
#include<iostream.h>
#include<conio.h>
class student
{
 char name[30],dep[30];
 const int RollNo;
 public:
   void getdata();
   void putdata();
};
void student::getdata()
{
 cout<<"\nEnter the Name : ";
 cin>>name;
 cout<<"\nEnter the department : ";
 cin>>dep;
}
void student::putdata()
{
 cout<<"\nStudent's Name:"<<name;
 cout<<"\nStudent's Roll No:"<<RollNo;
 cout<<"\nStudent's Department:"<<dep;
}
void main()
{
 clrscr();
 student JJ;
 JJ.getdata();
 JJ.putdata();
 getch();
}

ERROR:

Constant member  ‘student::RollNo’ in class without constructors
Previous
Next Post »

If you still didn't find what you're looking for, you can search this website below: