运行结果为空,麻烦各位uu帮忙看下原因,感谢🙇
/*程序运行结果为:
1321 samsung message send*/
//StudybarCommentBegin
#include<iostream>
#include<string.h>
using namespace std;
//#include <iostream.h>
class Telephone
{
protected :
int number;
public:
Telephone()
{number=1234;}
Telephone(int n)
{number=n;}
void showNumber()
{cout<<"my phone number is: "<<number<<endl;}
void call()
{cout<<"the phone is calling \n";}
};
class Mobile:public Telephone
{
char *type;
int cost;
public:
Mobile();
Mobile(char *t,int c, int n);
void message()
{cout<<number<<"\t"<<type<<"\tmessage send\n ";}
friend int operator<(Mobile &x1,Mobile &x2);
};
//StudybarCommentEnd
Mobile::Mobile(){}
Mobile::Mobile(char *t,int c, int n):Telephone(n)
{
cost = c;
strcpy(type,t);
}
int operator<(Mobile &x1, Mobile &x2)
{
int result(x1.number>x2.number?x2.number:x1.number);
return result;
}
//StudybarCommentBegin
int main()
{
Mobile m1;
Mobile m2("samsung",3500,1321);
if(m1<m2)
m1.message();
else
m2.message();
}
//StudybarCommentEnd