LogiQuest
Back to Objects and Classes
7

What will be the output of the program?

#include <iostream>
using namespace std;
class Rect {
    int w, h;
public:
    Rect(int a, int b) : w(a), h(b) {}
    int area() const { return w * h; }
};
int main() {
    Rect r(6, 7);
    cout << r.area() << endl;
    return 0;
}
Easy

Discussion (0)

  • No discussion yet. Ask a doubt or share a shortcut.

Log in to join the discussion.