Question: #include using std::cout; using std::endl; using std::ostream; #include using std::string; class MyClass{ private: long x_,y_; string s_; public: MyClass(long x, long y, string s=unknown) :

#include

using std::cout; using std::endl; using std::ostream;

#include

using std::string;

class MyClass{

private:

long x_,y_;

string s_;

public:

MyClass(long x, long y, string s="unknown") : x_(x), y_(y), s_(s) {};

string f1(long, long);

friend ostream& operator<<(ostream&, MyClass&);

};

string MyClass::f1(long x, long y){

if(x > x_ && y > y_)

s_ = "unset";

else if (x < x_ && y < y_)

s_ = "set";

else

s_ = "unknown";

return s_;

}

ostream& operator<<(ostream &out, MyClass &c){ // LINE 1

out << "(" << c.x_ << "," << c.y_ << "," << c.s_<< ")";

return out;

}

int main (){

MyClass c1(100,300);

MyClass c2(10, 30); // LINE 2

cout << c1 << endl; // LINE 3

cout << c2.f1(1000,3000)<

}

For the program shown in Figure 1, what is Line 2 called?

the two-arg constructor

the default constructor

not a constructor call

none of the listed answers

the three-arg constructor with a default on the third arg

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!