网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

请问下述代码中: int operator+(…)起什么作用?this 是什么?ccc 的值最终为多少?

class Fruit

{

public:

Fruit()

{

weight = 2;

}

Fruit(int w)

{

weight = w;

}

int operator+(Fruit f)

{

return this->weight * f.weight;

}

private:

int weight;

};

Fruit aaa;

Fruit bbb(4);

int ccc = aaa + bbb;


参考答案

更多 “ 请问下述代码中: int operator+(…)起什么作用?this 是什么?ccc 的值最终为多少?class Fruit{public:Fruit(){weight = 2;}Fruit(int w){weight = w;}int operator+(Fruit f){return this-weight * f.weight;}private:int weight;};Fruit aaa;Fruit bbb(4);int ccc = aaa + bbb; ” 相关考题
考题 Fruit is good for people.Many people eat some ___21___ every day. Mr and Mrs Black like fruit very much and every Monday Mrs Black goes to buy some fruit in the ___22___ near her house. The man in the shop knows her well and helps a lot. She can buy all ___23___ of fruit there, like apples, pears, oranges and bananas. In different time of the year the price of each kind of fruit is not the ___24___, sometimes high, something low. Mrs Black ___25___ to buy cheap fruit. But Mr Black likes bananas only. She buys bananas for him every week. She only buys cheap items for herself.21.A.shopB.sameC.likesD.kindsE.fruit22.A.shopB.sameC.likesD.kindsE.fruit23.A.shopB.sameC.likesD.kindsE.fruit24.A.shopB.sameC.likesD.kindsE.fruit25.A.shopB.sameC.likesD.kindsE.fruit

考题 请使用VC6或使用【答题】菜单打开考生文件夹proj2下的工程proj2,其中定义了vehiele类,并派生出motorcar类和bicycle类。然后以motorcar和bicycle作为基类,再派生出motorcycle类。要求将Vehicle作为虚基类,避免二义性问题。请在程序中的横线处填写适当的代码并删除横线,以实现上述类定义。此程序的正确输出结果应为:801501001注意:只能在横线处填写适当的代码,不要改动程序中的其他内容,也不要删除或移动“//****found****”。includeiostream.hclass vehicle{private:int MaxSpeed;int Weight;public://*************found************vehicle(int maxspeed,int weight):——~vehicle{};int getMaxSpeed{return MaxSpeed;}int getWeight{retum Weight;}};//****************found************class bicycle:——public vehicle{private:int Height;public:bicycle(int maxspeed,int weight,int height):vehicle(maxspeed,weight),Height(height){}int getHeight{retum Height;};};//*******************found**************class motorcar:——public vehicle{private:int SeatNum;public:motorcar(int maxspeed。int weight,int seatnum):vehicle(maxspeed,weight),SeatNum(seatnum){}int getSeatNum{return SeatNum;};};//*****************found***************class motorcycle:——{public:motorcycle(int maxspeed,int weight,int height):vehicle(maxspeed,weight),bicycle(maxspeed,weight,height),motorcar(maxspeed,weight,1){}};void main{motorcycle a(80,150,100);couta.getMaxSpeedendl;couta.getWeightendl;couta.getHeightendl;couta.getSeatNumendl;}

考题 下面这个程序的结果是includeclass A{private:int a;public:void seta();int geta( 下面这个程序的结果是 #include<iostream.h> class A { private: int a; public: void seta();int geta();}; void A∷seta() {a=1;} int A∷geta() {return a;} class B { pnvate: int a; publiC: void sera();int geta();}; void B∷seta() {a = 2;} int B∷geta() {return a;} class C:public A,public B { private: int b; public: void display();}; void C∷display() { int b=geta(); cout<<b;} void main() { C c; c.seta(); c.display();}A.1B.2C.随机输出1或2D.程序有错

考题 下面这个程序的结果是 include class A { private: int a; public: void seta( ) ; 下面这个程序的结果是#include<iostream.h>class A{private:int a;public:void seta( ) ;int geta( ) ;};void A: :seta( ){ a=1;}int A: :geta( ){ retum a;}class B{ private:int a;public:void seta( ) ;int geta( ) ;};void B: :seta( ){a=2;}int B: :geta( ){return a;}class C: public A,public B{ private:int b;public:void display( ) ;};void C: :display( ){ int b=geta( ) ;cout < < b;}void main( ){ C c;c. seta( ) ;c. display( ) ;}A.1B.2C.随机输出1或2D.程序有错

考题 若有以下程序:include using namespace std;class A{private:int x;public:int z;voi 若有以下程序:#include <iostream>using namespace std;class A{private: int x;public: int z; void setx(int i) { x=i; } int getx() { return x; }};class B: public A{private: int m;public: int p; void setvalue(int a, int b, int c) { setx(a); z=b; m=c; } void display() { cout<<getx()<<","<<z<<","<<m<<end1; }};int main(){ B obj; obj.setvalue(2,3,4); obj.display(); return 0;程序运行以后的输出结果是( )A.产生语法错误B.2,3,4C.2,2,2D.4,3,2

考题 下列选项成员变量声明正确的是A.public protected final int i;B.abstract class F1{…}C.private double height;D.double weight{}

考题 有以下程序:include using namespace std;class A{private: int x,y;public: void se 有以下程序: #include <iostream> using namespace std; class A { private: int x,y; public: void set (int i,int j) { x=i; y=j; } int get_y() { return y; } }; class box { private: int length,width; A label; public: void set(int 1,int w, int s,int p) { length=1; width=w; label.set(s,p); } int get_area() { return length*width; } }; int main() { box small; small.set(2,4,1,35); cout<<small.get_area()<<end1; return 0; } 运行后的输出结果是( )。A.8B.4C.35D.70

考题 下列成员变量声明中,正确的是______。A.public protected final int i;B.abstract class F1{…}C.private double height;D.double weight

考题 调用函数bbb后,输出是什么void ccc(int x){char szTemp[10] = "";x = 2;sprintf(szTemp, "%d,", x);afxDump szTemp;if(x = 3){int x = 4;sprintf(szTemp, "%d,", x);afxDump szTemp;}sprintf(szTemp, "%d,", x);afxDump szTemp;}void bbb(){char szTemp[10] = "";int x = 7;ccc(x);sprintf(szTemp, "%d,", x);afxDump szTemp;}

考题 int func1(int b){return 0;}void func2(){int bbb = 3;func1(bbb);func1(bbb);}func2中有何错误,func1的参数b 的类型是什么。

考题 请解释“func”为何种类型,这种类型的作用什么,变量ttt 的值是多少?typedef int (*func)(int, int*);int xxx(int a, int *p){return a + *p;}int dowork(func aaa, int bbb, int *ccc){return aaa(bbb, ccc);}int sss = 4;int ttt = dowork(xxx, 3, sss);

考题 下列中 a的值是_________#define AAA 200#define BBB AAA+100int a= BBB*2

考题 有下列程序:includeUsing namespace std;Class Amount{ int amount;public; Amount(i 有下列程序: #include<iostream> Using namespace std; Class Amount{ int amount; public; Amount(int n=O):amount(n){} Int getAmount()const{return amount;} Amount operator+=(AmountA) {A.*thisB.thisC.amountD.amount

考题 以下关于Python自带数据结构的运算结果中正确的是哪一项? A.l = [1, 2, 3, 4, 5]; del l[2:4]; 则运算之后l为[1,2, 3]。B.basket = ['apple', 'banana', 'apple', 'orange'] ;fruit = set(basket);fruit2 = set(['apple', 'melo']); len(fruit |fruit2) 的结果是5。C.basket = ['apple', 'banana', 'apple', 'orange'] ;fruit = set(basket); len(fruit) 的运算结果是4。D.l = [2, 1, 3, 5, 4]; l.remove(3); l.sort(); 则运算之后l为[1, 2, 4, 5]

考题 若有以下程序:includeusing namespace std;class A{private:int x;public:int z;void 若有以下程序:#include<iostream>using namespace std;class A {private: int x;public: int z; void setx(int i) { x=i; } int getx () { return x; }}:class B : public A{private: int m;public: int p; void setvalue(int a, int b, int c) { setx(a) ; z=b; m=c; } void display{) { cout<<getx ()<<", "<<z<<", "<<m<<end1; }};int main(){ B obj; obj. setvalue(2,3,4); obj.display(); return 0;} 程序运行以后的输出结果是A.产生语法错误B.2,3,4C.2,2,2D.4,3,2

考题 下列对shell变量FRUIT操作,正确的是() A.为变量赋值:$FRUIT=appleB.显示变量的值:fruit=appleC.显示变量的值:echo $FRUITD.判断变量是否有值:[-f“$FRUIT”]

考题 下列对shell变量FRUIT操作,正确的是()A、为变量赋值:$FRUIT=appleB、显示变量的值:fruit=appleC、显示变量的值:echo $FRUITD、判断变量是否有值:[-f“$FRUIT”]

考题 class A {  protected int method1(int a, int b) { return 0; }  }  Which two are valid in a class that extends class A?() A、 public int method1(int a, int b) { return 0; }B、 private int method1(int a, int b) { return 0; }C、 private int method1(int a, long b) { return 0; }D、 public short method1(int a, int b) { return 0: }E、 static protected int method1(int a, int b) { return 0; }

考题 Given:  1. public class Method Over {  2. public void set Var (int a, int b, float c) {  3. }  4. }   Which two overload the set Var method()?A、 private void set Var(int a, float c, int b) {}B、 protected void set Var(int a, int b, float c) {}C、 public int set Var(int a, float c, int b) {return a:}D、 public int set Var(int a, int b, float c) {return a:}E、 protected float set Var(int a, int b, float c) {return c:}

考题 Assuming that the serializeBanana2() and the deserializeBanana2() methods will correctly use Java serialization and given:  import java.io.*;  class Food {Food() { System.out.print(”1”); } }  class Fruit extends Food implements Serializable {  Fruit() { System.out.print(”2”); } }  public class Banana2 extends Fruit { int size = 42;  public static void main(String [] args) {  Banana2 b = new Banana2();  b.serializeBanana2(b); // assume correct serialization  b = b.deserializeBanana2(b); // assume correct  System.out.println(” restored “+ b.size + “ “); }  // more Banana2 methods  }  What is the result?() A、 Compilation fails.B、 1 restored 42C、 12 restored 42D、 121 restored 42E、 1212 restored 42F、 An exception is thrown at runtime.

考题 public class Score implements Comparable {  private int wins, losses;  public Score(int w, int 1) { wins = w; losses = 1; }  public int getWins() { return wins; }  public int getLosses() { return losses; }  public String toString() {  return ““ + wins + “,“ + losses + “”; }  // insert code here  }  Which method will complete this class?() A、 public int compareTo(Object o) {/*mode code here*/}B、 public int compareTo(Score other) {/*more code here*/}C、 public int compare(Score s1,Score s2){/*more code here*/}D、 public int compare(Object o1,Object o2){/*more code here*/}

考题 11. class Payload {  12. private int weight;  13. public Payload(int wt) { weight = wt; }  13. public void setWeight(mt w) { weight = w; }  15. public String toString { return Integer.toString(weight); }  16. }  17.  18. public class TestPayload {  19. static void changePayload(Payload p) { 20. /* insert code here */ 21. }  22.  23. public static void main(String[] args) {  24. Payload p = new Payload();  25. p.setWeight(1024);  26. changePayload(p);  27. System.out.println(”The value of p is “+ p);  28. }  29. }  Which statement, placed at line 20, causes the code to print “The value of p is 420.”?() A、 p.setWeight(420);B、 p.changePayload(420);C、 p = new Payload(420);D、 Payload.setWeight(420);E、 p = Payload.setWeight(420);F、 p = new Payload(); p.setWeight(420);

考题 public class MethodOver  {  public void setVar (int a, int b, float c)  {  }  }   Which two overload the setVar method?()  A、 Private void setVar (int a, float c, int b)  { }B、 Protected void setVar (int a, int b, float c) { }C、 Public int setVar (int a, float c, int b) (return a;)D、 Public int setVar (int a, int b, float c) (return a;)E、 Protected float setVar (int a, int b, float c) (return c;)

考题 Assuming that the serializeBanana() and the deserializeBanana() methods will correctly use Java serialization and given:  import java.io.*;  class Food implemertts Serializable {int good = 3;}  class Fruit externds Food {int juice = 5;}  public class Banana extends Fruit {  int yellow = 4;  public static void main(String [] args) {  Banana b = new Banana(); Banana b2 = new Banana();  b.serializeBanana(b); // assume correct serialization  b2 = b.deserializeBanana(); // assume correct  System.out.println(”restore “+b2.yellow+ b2.juice+b2.good);  }  // more Banana methods go here  }  What is the result?() A、 restore 400B、 restore 403C、 restore 453D、 Compilation fails.E、 An exception is thrown at runtime.

考题 public abstract class Shape {  private int x;  private int y;  public abstract void draw();  public void setAnchor(int x, int y) {  this.x = x;  this.y = y;  }  }  Which two classes use the Shape class correctly?()A、 public class Circle implements Shape { private int radius; }B、 public abstract class Circle extends Shape { private int radius; }C、 public class Circle extends Shape { private int radius; public void draw(); }D、 public abstract class Circle implements Shape { private int radius; public void draw(); }E、 public class Circle extends Shape { private int radius;public void draw() {/* code here */} }F、 public abstract class Circle implements Shape { private int radius;public void draw() { / code here */ } }

考题 1. public class Blip {  2. protected int blipvert(int x) { return 0; }  3. }  4. class Vert extends Blip {  5. // insert code here  6. }  Which five methods, inserted independently at line 5, will compile?()  A、 public int blipvert(int x) { return 0; }B、 private int blipvert(int x) { return 0; }C、 private int blipvert(long x) { return 0; }D、 protected long blipvert(int x, int y) { return 0; }E、 protected int blipvert(long x) { return 0; }F、 protected long blipvert(long x) { return 0; }G、protected long blipvert(int x) { return 0; }

考题 单选题Assuming that the serializeBanana() and the deserializeBanana() methods will correctly use Java serialization and given:  import java.io.*;  class Food implemertts Serializable {int good = 3;}  class Fruit externds Food {int juice = 5;}  public class Banana extends Fruit {  int yellow = 4;  public static void main(String [] args) {  Banana b = new Banana(); Banana b2 = new Banana();  b.serializeBanana(b); // assume correct serialization  b2 = b.deserializeBanana(); // assume correct  System.out.println(”restore “+b2.yellow+ b2.juice+b2.good);  }  // more Banana methods go here  }  What is the result?()A  restore 400B  restore 403C  restore 453D  Compilation fails.E  An exception is thrown at runtime.