#include<iostream>
using namespace std;
class circle
{
public:
int r;
getr()
{
cout<<"enter radius";
cin>>r;
}
area()
{
cout<<"area is "<<(3.14*r*r);
}
}
int main()
{
circle one;
one.getr();
one.area();
return 0;
}
Im getting the following errors:
g++ /tmp/E854sHhnHj.cpp /tmp/E854sHhnHj.cpp:8:10: error: ISO C++ forbids declaration of 'getr' with no type [-fpermissive] 8 | getr() | ^
/tmp/E854sHhnHj.cpp:13:10: error: ISO C++ forbids declaration of 'area' with no type [-fpermissive] 13 | area() | ^
/tmp/E854sHhnHj.cpp:17:2: error: expected ';' after class definition 17 | } | ^ | ; /tmp/E854sHhnHj.cpp: In member function 'int circle::getr()':
/tmp/E854sHhnHj.cpp:12:5: warning: no return statement in function returning non-void [-Wreturn-type] 12 | } | ^
/tmp/E854sHhnHj.cpp: In member function 'int circle::area()': /tmp/E854sHhnHj.cpp:16:5: warning: no return statement in function returning non-void [-Wreturn-type] 16 | } | ^
void getr()
– Damien