LogiQuest
Back to Operator Overloading
10

What will be the output of the program?

#include <iostream>
using namespace std;
struct V {
    int x, y;
};
ostream &operator<<(ostream &os, const V &v) { return os << "(" << v.x << "," << v.y << ")"; }
int main() {
    V v{2, 5};
    cout << v << endl;
    return 0;
}
Easy

Discussion (0)

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

Log in to join the discussion.