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
Source Code Solutions
C++ Programs
Object Oriented Programming Lab
OOPS Lab
CLASSES WITH CONSTANT DATA MEMBERS
Next
« Prev Post
« Prev Post
Previous
Next Post »
Next Post »
Subscribe to:
Post Comments (Atom)
EmoticonEmoticon