what's wrong?

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;
}
 
?

=?ISO-8859-2?Q?Mihajlo_Cvetanovi=E6?=

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>
 
J

Jason Felix

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>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top