Jul 3, 2012 at 5:03pm UTC
Please explain the principle of operation of this program?!
#include <iostream>
using namespace std;
class CRectangle {
int width, height;
public:
CRectangle ();
CRectangle (int,int);
int area (void) {return (width*height);}
};
CRectangle::CRectangle () {
width = 5;
height = 5;
}
CRectangle::CRectangle (int a, int b) {
width = a;
height = b;
}
int main () {
CRectangle rect (3,4);
CRectangle rectb;
cout << "rect area: " << rect.area() << endl;
cout << "rectb area: " << rectb.area() << endl;
system("PAUSE");
return EXIT_SUCCESS;
}
Jul 3, 2012 at 5:23pm UTC
What do YOU think it does???
Jul 3, 2012 at 5:48pm UTC
This programm calculate rect area, but I want to know how the program does this?!
Jul 3, 2012 at 6:36pm UTC
Take it apart.
Do you understand what the default constructor does?
Do you understand what the explicit constructor does?
Do you understand what the area function does?
Do you understand what the cout statements do?
Jul 4, 2012 at 2:04am UTC
Why you don't answer on my question?
Jul 4, 2012 at 3:10am UTC
Why don't you try yourself? We don't hold hands here. We will help you, once you show some sort of effort yourself.
Jul 4, 2012 at 5:35am UTC
You are lazy, you can't write me a simple programm!!! Help me!
Jul 4, 2012 at 5:56am UTC
Wait, I'm lazy? Because I won't write your program?
Help yourself. I'm done trying to help you.
Jul 4, 2012 at 8:25am UTC
I wanna help, but it seems like you're demanding rather than asking for help.
so ...
Jul 4, 2012 at 10:35am UTC
What about demands - I make fun of them! No offense! Today I passed the program on C++, and excellent pass the exam of computer science!
Jul 4, 2012 at 11:44am UTC
Its fun for you, not for anyone else apparently.
And I do wonder how you passed the program (excellent) without understanding such a basic program like the one you posted.
unless I read your sentence wrong