i can't see the differance between my code and the example one in the tutorial under clases 1. i copyed the one in he tutorial by typing it instead of copying and pasting to help me remember howerver i can't see the differance brween mine and the example exept mine won't run and the exanple will the first ones mine(it won't run) and the second one is the example
#include <iostream>
usingnamespace std;
class recg {
int x,y;
public:
void go (int,int);
int area () {return (x*y);}
};
void recg::go (int a,int b){
x = a;
y = b;
}
int main () {
recg rec,reca;
rec.go (4,3);
reca.go (20,5);
cout<<"4 by 3="<<rec.go()<<endl;
cout<<"\n20 by 5="<<reca.go()<<endl;
cout<<"\n\n\n";
return (0);
}
When you call rec.go() at line 20 you forgot to pass the two integers that the function takes as arguments...
[EDIT] Or if you need to call area, you used the wrong function name, as Grey Wolf said
@Grey Wolf
Sorry about that, I was reading something else from Zaita that's why the wrong name. I didn't want to offend you. It was just a type mistake, I corrected it.
Sorry again.
@hamo94
It works fine for me if you change the ".go()" with ".area();
#include <iostream>
usingnamespace std;
class recg {
int x,y;
public:
void go (int,int);
int area () {return (x*y);}
};
void recg::go (int a,int b){
x = a;
y = b;
}
int main () {
recg rec,reca;
rec.go (4,3);
reca.go (20,5);
cout<<"4 by 3="<<rec.area()<<endl;
cout<<"\n20 by 5="<<reca.area()<<endl;
cout<<"\n\n\n";
return (0);
}
@Grey Wolf: It's the Zen of question answering. I have become so elite, now I don't even have to answer the questions. I get credit for other ppl's answers :P
@Grey Wolf
Sorry about that, I was reading something else from Zaita that's why the wrong name. I didn't want to offend you. It was just a type mistake, I corrected it.
Sorry again.
You didn't offend me, I was just concerned that there may have been a problem with the forum. As I said there was a least one other occasion of a miss quote, I have also seen posts from other that seemed to be "out side of there normal posting times".