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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started