error "extra qualification ‘student::’ on member ‘student’ [-fpermissive] "
61,604
Solution 1
In-class definitions of member function(s)/constructor(s)/destructor don't require qualification such as student::
.
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.
Solution 2
It would be correct if definition of constructor would appear outside of class definition.

Author by
wizneel
Updated on July 09, 2022Comments
-
wizneel 6 months
I am getting an error
extra qualification ‘student::’ on member ‘student’ [-fpermissive]
.
And also whyname::name
such syntax is used in constructor?#include<iostream> #include<string.h> using namespace std; class student { private: int id; char name[30]; public: /* void read() { cout<<"enter id"<<endl; cin>>id; cout<<"enter name"<<endl; cin>>name; }*/ void show() { cout<<id<<name<<endl; } student::student() { id=0; strcpy(name,"undefine"); } }; main() { student s1; // s1.read(); cout<<"showing data of s1"<<endl; s1.show(); // s2.read(); //cout<<"showing data of s2"<<endl; //s2.show(); }
-
wizneel over 10 yearswhat is the use of such qualification or when we have to use it
-
Nawaz over 10 years@user1306088: The qualification
student::
is required only if you define the function outside the class, usually in .cpp file.