下列程序对加号进行了重载,划线部分的语句是______。 include include class下列程序对加号进行了重载,划线部分的语句是______。include<iostream.h>include<math.h>class Triangle{int x,y,z;double area;public:Triangle(int i,int j,int k){double s;x=i;y=j;z=k;s=(x+y+z)/2.0;area=sqrt(s*(s-x)*(s-y)*(s-z));}void

题目
下列程序对加号进行了重载,划线部分的语句是______。 include include class

下列程序对加号进行了重载,划线部分的语句是______。

include<iostream.h>

include<math.h>

class Triangle

{

int x,y,z;

double area;

public:

Triangle(int i,int j,int k)

{

double s;

x=i;y=j;z=k;

s=(x+y+z)/2.0;

area=sqrt(s*(s-x)*(s-y)*(s-z));

}

void disparea( )

{

cout<<"Area="<<area<<endl;

}

friend double operator+(Triangle tl,Triangle t2)

{

______

}

};

void main( )

{

Triangle tl(3,4,5),t2(5,12,13);

double s;

cout<<"tl:";t1. disparea( );

cout<<"t2:";t2. disparea( );

s=t1+t2:

cout<<"总面积:="<<s<<endl;

}


相似考题
参考答案和解析
正确答案:return tl.area+t2.area;
return tl.area+t2.area; 解析:符号重载时往往采用的方法是对对象中的每个成员分别处理,封装之后体现出对象参与运算的现象。
更多“下列程序对加号进行了重载,划线部分的语句是______。 include<iostream.h> include<math.h> class ”相关问题
  • 第1题:

    在C程序中如果要使用数学函数,如sqrt(x),pow(x,y)等,需要在程序中加入的语句是______

    A.#define <math.h>

    B.#define <stdio.h>

    C.#include <stdio.h>

    D.#include <math.h>


    C

  • 第2题:

    2、在C程序中如果要使用数学函数,如sin(x),log(x)等,需要在程序中加入的语句是

    A.#include <math.h>

    B.#include <stdio.h>

    C.#define <math.h>

    D.#define <stdio.h>


    A

  • 第3题:

    在C程序中如果要使用数学函数,如sin(x),log(x)等,需要在程序中加入的语句是________。

    A.#include <math.h>

    B.#include <stdio.h>

    C.#define <math.h>

    D.#define <stdio.h>


    C

  • 第4题:

    16、在C程序中如果要使用数学函数,如sin(x),log(x)等,需要在程序中加入的语句是

    A.#include <math.h>

    B.#include <stdio.h>

    C.#define <math.h>

    D.#define <stdio.h>


    #include

  • 第5题:

    在C程序中如果要使用数学函数,如sin(x),log(x)等,需要在程序中加入的语句是()

    A.#include <stdio.h>

    B.#define <stdio.h>

    C.#include <math.h>

    D.#define <math.h>


    #include