error “extra qualification ‘student::’ on member ‘student’ [-fpermissive] ”

image_pdfimage_print

I am getting an error extra qualification ‘student::’ on member ‘student’ [-fpermissive].
And also why name::name such syntax is used in constructor?

#include
#include
using namespace std;
class student
{
 private:
     int id;
     char name[30];
 public:
/*   void read()
     {
        cout<<"enter id"<>id;
        cout<<"enter name"<>name;
     }*/
     void show()
     {
        cout<
SOLUTION ..

In-class definitions of member function(s)/constructor(s)/destructor don't require qualification such asstudent::.

So this code,

 student::student()
 {
    id=0;
    strcpy(name,"undefine");
 }

should be this:

 student()
 {
    id=0;
    strcpy(name,"undefine");
 }

The qualification student:: is required only if you define the member functions outside the class, usually in .cpp file.




This entry was posted in C++/C. Bookmark the permalink.