what's wrong?

  • Thread starter Thread starter Jason Felix
  • Start date Start date
J

Jason Felix

#include<iostream>
using namespace std;

class MyClass{
public:
int x;
MyClass(int i);
}

MyClass::MyClass(int i){
x=i;
}

int main(){
MyClass ob(5);
cout<<ob.x<<"\n";
return 0;
}
 
Jason said:
class MyClass{
...
}
^
You need a semicolon here: };

If this wasn't some sort of quiz question then I suggest that the next
time you give us some symptoms along with the question, like:

<imaginary quote>
The compiler gives this message, and I don't understand what it means:
error C2533: 'MyClass::__ctor' : constructors not allowed a return type

I won't bother with googling since it might turn me more experienced,
and is generally considered as a total waste of time. What's wrong?
</imaginary quote>
 
i am so sorry. thank you for your advice.
Mihajlo Cvetanoviæ said:
^
You need a semicolon here: };

If this wasn't some sort of quiz question then I suggest that the next
time you give us some symptoms along with the question, like:

<imaginary quote>
The compiler gives this message, and I don't understand what it means:
error C2533: 'MyClass::__ctor' : constructors not allowed a return type

I won't bother with googling since it might turn me more experienced, and
is generally considered as a total waste of time. What's wrong?
</imaginary quote>
 
Back
Top