有以下定义:classBox{intwidth,length,height;public:voidset(intx=0,inty=0,intz=0){width=x;length=y;height=z;}};Box*box;则以下哪种使用是正确的___
A: box->width=3;
B: coutC: box->set(1,2);
D: p.set(1,2);
A: box->width=3;
B: cout
D: p.set(1,2);
举一反三
- 有以下定义: class Box{ int width,length,height; public: void set(int x=0,int y=0,int z=0) {width=x;length=y;height=z;} }; Box *box; 则以下哪种使用是正确的___
- 下列程序的输出结果为 class Box{ int length,width,height; public void setInfo(int l,int w,int h){ length = l; width = w; height = h; } public int volumn(){ return length*width*height; } public int area(){ return (length*width + length*height + width*height) * 2; } public String toString(){ return "Length:" + length + " width:" + width + " height:" + height + " volumn: " + volumn() + " area:" + area(); }} public class BoxTest { public static void main(String[] args) { Box b = new Box(); b.setInfo(5,2,4); System.out.println(b.toString()); }}
- 【填空题】用拷贝构造函数进行对象构造。 #include<iostream> using namespace std; class Box { public: Box(int h,int w,int len); //构造函数声明 ( 1 ) //拷贝构造函数声明 int volume(); //求立方体体积函数 private: int height; int width; int length; }; Box::Box(int h,int w,int len) { height=h; width=w; length=len; } Box::Box(Box &a) { height=a.height+5; width=a.width+5; length=a.length+5; } int Box::volume() { return(height*width*length); } void main() { Box box1(5,5,5); cout<<"The volume of box
- 在以下代码片段中,属于绝对定位的是() A: #box {width:100px;height:50px;position:absolute;} B: #box (width:100px;height:50px;position:relative;} C: #box {width:100px;height:50px;position:static;} D: #box {width:100px;height:50px;}
- 在以下代码片段中,属于绝对定位的是()。 A: box {width:100px;height:50px;} B: box {width:100px;height:50px;position:absolute;} C: box {width:100px;height:50px;position:static;} D: box (width:100px;height:50px;position:relative;}