+ 1
During execution, the only error is "Unexpected unqualified-id before { token. (3rd line}. Pls. do help to fix the error.
#include <iostream> class ABC; { private:int data; public:void getdet(); { cout<<"Enter Number:"; cin>>data; cout<<"The number entered is:"<<data; } }; void main() { ABC obj; obj.getdet(); }
1 Antwort
+ 4
#include <iostream>
using namespace std; // <- this wasn't here
class ABC // there was a semicolon here
{
private:
int data;
public:
void getdet()// there was a semicolon here
{
cout<<"Enter Number:";
cin>>data;
cout<<"The number entered is:"<<data;
}
};
int main() // this was void main()
{
ABC obj;
obj.getdet();
}
Hth, cmiiw