What is the error ISO C++ forbids declaration of 'getdata' with no type [-fpermissive]|

0 Vinit Sonavane · July 11, 2014
error: ISO C++ forbids declaration of 'getdata' with no type [-fpermissive]
 ISO C++ forbids declaration of 'display' with no type [-fpermissive]
=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===


My program is:

#include<iostream>
#include<stdio.h>
#include<conio.h>
using namespace std;
class student
{
    int rollno;
    int marks;
public:
    getdata()
    {
        cout<<"Enter roll no:";
        cin>>rollno;
        cout<<"Enter Marks:";
        cin>>marks;
    }
    display()
    {
        cout<<"Roll No="<<rollno;
        cout<<"Marks="<<marks;
    }
};
int main(void)
{

    student s1;
    s1.getdata();
    s1.display();
    getch();
}

Post a Reply

Replies

Oldest  Newest  Rating
0 Vinit Sonavane · September 26, 2014
Thanx fixed that prob bro
-3 Daniel Collier · July 11, 2014
LOL BR IS FUCKED #YOLOSWAG
-1 Daniel Collier · July 11, 2014
<ol class="linenums" style="font-family: monospace; font-size: 12px; padding-left: 15px; white-space: pre;"><li class="L0" style="margin-left: 30px;">#include<iostream>[/*]<li class="L1" style="margin-left: 30px; background: rgb(238, 238, 238);">#include<stdio.h>[/*]<li class="L2" style="margin-left: 30px;">#include<conio.h>[/*]<li class="L2" style="margin-left: 30px;">
[/*]<li class="L3" style="margin-left: 30px; background: rgb(238, 238, 238);">using namespace std;[/*]<li class="L3" style="margin-left: 30px; background: rgb(238, 238, 238);">
[/*]<li class="L4" style="margin-left: 30px;">class student[/*]<li class="L5" style="margin-left: 30px; background: rgb(238, 238, 238);">{[/*]<li class="L5" style="margin-left: 30px; background: rgb(238, 238, 238);">protected:[/*]<li class="L6" style="margin-left: 30px;">private:[/*]<li class="L7" style="margin-left: 30px; background: rgb(238, 238, 238);"> int rollno;[/*]<li class="L8" style="margin-left: 30px;"> int marks;[/*]<li class="L9" style="margin-left: 30px; background: rgb(238, 238, 238);">public:[/*]<li class="L0" style="margin-left: 30px;"> void getdata();[/*]<li class="L7" style="margin-left: 30px; background: rgb(238, 238, 238);"> void display();[/*]<li class="L2" style="margin-left: 30px;">};[/*]<li class="L2" style="margin-left: 30px;">
[/*]<li class="L3" style="margin-left: 30px; background: rgb(238, 238, 238);">int main(void)[/*]<li class="L4" style="margin-left: 30px;">{[/*]<li class="L5" style="margin-left: 30px; background: rgb(238, 238, 238);"> [/*]<li class="L6" style="margin-left: 30px;"> student s1;[/*]<li class="L7" style="margin-left: 30px; background: rgb(238, 238, 238);"> s1.getdata();[/*]<li class="L8" style="margin-left: 30px;"> s1.display();[/*]<li class="L9" style="margin-left: 30px; background: rgb(238, 238, 238);"> getch();[/*]<li class="L9" style="margin-left: 30px; background: rgb(238, 238, 238);">}[/*][/list]



#include "student.h"

void student::getdata()
{
cout<<"Enter roll no:";
cin>>rollno;
cout<<"Enter Marks:";
cin>>marks;
}

void student::display()
{
cout<<"Roll No="<<rollno;
cout<<"Marks="<<marks;
}

-1 Daniel Collier · July 11, 2014

#include<iostream>
#include<stdio.h>
#include<conio.h>
using namespace std;
class student
{
private:
int rollno;
int marks;
public:
void getdata()
{
cout<<"Enter roll no:";
cin>>rollno;
cout<<"Enter Marks:";
cin>>marks;
}
void display()
{
cout<<"Roll No="<<rollno;
cout<<"Marks="<<marks;
}
};
int main(void)
{

student s1;
s1.getdata();
s1.display();
getch();
}


new code
-1 Daniel Collier · July 11, 2014
you have forgot to put the return type on your methods
+1 Franz Schmidt · July 11, 2014
You need a data type for the functions in the class:

#include<iostream>
#include<stdio.h>
#include<conio.h>
using namespace std;
class student
{
int rollno;
int marks;
public:
void getdata()
{
cout<<"Enter roll no:";
cin>>rollno;
cout<<"Enter Marks:";
cin>>marks;
}
void display()
{
cout<<"Roll No="<<rollno;
cout<<"Marks="<<marks;
}
};
int main(void)
{

student s1;
s1.getdata();
s1.display();
getch();
}

  • 1

C++

107,277 followers
About

Used in many types of software including music players, video games, and many large scale applications.

Links
Moderators
Bucky Roberts Administrator