includeiostream.hclass A{private:int x,y;public:void f1(int i=0,int j=0){x=i;y=j;}void print(){coutx yendl;}void f1(int i=0){x=i,y=0;}};void main(){A a;a.f1(5);a.print();}
include<iostream.h>
class A
{
private:
int x,y;
public:
void f1(int i=0,int j=0){x=i;y=j;}
void print(){cout<<x<<" "<<y<<endl;}
void f1(int i=0){x=i,y=0;}
};
void main()
{
A a;
a.f1(5);
a.print();
}
相关考题:
下列程序的输出结果是非曲直【 】。includeclass base{ int x, y;public: base(int i, 下列程序的输出结果是非曲直【 】。include<iostream, h>class base{int x, y;public:base(int i, int j){x=i; y=j;}virtual int add(){return x+ y;}};class three: public base{int z;public:three(int i, int j, int k) :base(i, j){z=k; }int add() { return (base:: add()+z); }};void main(){three * q=new three(lO,20,30);cout<<q->add()<<end1;}
有如下程序:includeusing namespace std;Class TestClass{private:int x,y;public:Te 有如下程序: #include<iostream> using namespace std; Class TestClass { private: int x,y; public: TestClass(int i,int j) { x=i; y=j; } void print() { cout<<“print1”<<endl; } void print()const { cout<<”prinA.printlB.print2C.printl print2D.程序编译时出错。
本题中,鼠标在窗口中单击一下,就在单击的位置生成一个小矩形,如果在小矩形上双击鼠标左键,则删除小矩形。 import java.awt.*; import java.awt.event.*; import javax swing.*; class MousePanel extends JPanel extends MouseMo- tionListener {public MousePanel {addMouseListener(new MouseAdapter {public void mousePressed(MouseEvent evt) {int X=evt.getX; int Y=evt.getY; current=find(x,y); if(current0) add(x,y); } public void mouseClicked(MouseEvent evt) {int X=evt.getX; int Y=evt.getY; if(evt.getClickCount=2) {remove(current); } } }); addMouseMotionListener(this); } public void paintComponent(Graphics g) {super.paintComponent; for(int i=0;insquares;i++) draw(g,i); } public int find(int X,int y) (for(int i=0;insquares;i++) if(squares[i].x-SQUARELENGTH/2= x X=squares[i].x+SQuARELENGTH/2 squares[i].Y-SQUARELENGTH/2 =Y y=squares[i].Y+SQUARELENGTH /2) return i ; return-1 ; } public void draw(Graphics g,int i) {g.drawRect(squares[i].X-SQUARE- LENGTH/2。 squares[i].Y-SQUARELENGTH/2, SQUARELENGTH, SQUARELENGTH); } public void add(int X,int Y) {if(nsquaresMAXNSQUARES) {squares[nsquares]=new Point(x,y); current=nsquares ; nsquares++; repaint; } } public void remove(int n) {if(n0 ‖ n=nsquares)return; Nsquares- -; squares[n]=squares[nsquares]; if(current= =n)current= -l; repaint; } public void mouseMoved(MouseEvent evt) {} public void mouseDragged(MouseEvent evt) {} private static final int SQUARELENGTH=10: private static final int MAXNSQUARES=100; private Point[]squares=new Point[MAX- NSQUARES]; private int nsquares=0; private int current=-l; } class MouseFrame. extends JFramc {public MouseFrame {setTitle("java3"); setSize(300,200); addWindowListener(new WindowAdapter {public void windowClosing(WindowEvent e) {System.exit(0); } }); Container contentPane=getContentPane; contentPane.add(MousePanel); } } public class java3 {public static void main(String[]args) {JFrame. frame=new MouseFrame; frame.show; } }
在下面的类定义中,this指针的用途是______。 include class Sample { int x,y; publi 在下面的类定义中,this指针的用途是______。include<iostream.h>class Sample{int x,y;public:Sample(int i,int j){x=i;y=j;}void assign(Sample sa);};void Sample::assign(Sample p){if(this!=p){x=p.x;y=p.y;}}
有如下程序:include using namespace std;class sample{private:int x,y;public: sam 有如下程序: #include <iostream> using namespace std; class sample { private: int x,y; public: sample(int i,int j) { x=i; y=j; } void disp () { cout<<"disp1"<<end1; } void disp() const { cout<<"disp2"<<end1; };int main () { const sample a(1,2); a.disp(); return 0; } 该程序运行后的输出结果是A.disp1B.disp2C.disp1 disp2D.程序编译时出错
下列程序的运行结果是 includeclass Location{private:int X.Y;public:void init(i 下列程序的运行结果是 #include<iostream.h> class Location{ private: int X.Y; public: void init(int=0,int=0); void valueX(int val){X=val;} int valueX( ){ return X;} void valueYA.5 0 6 4B.0 0 6 4C.5 0 6 2D.0 0 6 2
下列程序的输出结果是includeclass Myclass{public:Myclass(int i=0,int j=0){x=i; 下列程序的输出结果是 #include<iostream.h> class Myclass{ public:Myclass(int i=0,int j=0) { x=i; y=j; } void show( ) {cout < <"x=" < < x < <" " <"y=" < < y < < endl;} void show( ) const{cout < <"x=" < <" " < <"y=" < < y < < endl;} privated: int x; int y; }; void main( ) { Myclass my1(3,4) ; const my2(7,8) ; my1.show( ) ;my2.show( ) ;}A.x=4,y=3;x=7,y=8B.x=3,y=4;x=7,y=8C.x=7,y=8;x=4,y=3D.x=8,y=7;x=7,y=8
有以下程序:include using namespace std;class myclass{private: int a,b;public: v 有以下程序: #include <iostream> using namespace std; class myclass { private: int a, b; public: void init( int i, int j ) { a = i; b = j; } friend int sum( myclass x ); }; int sum( myclass x ) { return x.a + x.b; } int main () { myclass y; y.init( 15, 20 ); cout<<sum( y )<<end1; return 0; } 执行后的输出结果是( )。A.15B.20C.5D.35
下列程序的输出结果是includeclass Myclass{public : Myclass( int i=0,int j=0){x 下列程序的输出结果是 #include<iostream.h> class Myclass{ public : Myclass( int i=0,int j=0) {x=i; y=j; } void show( ){cout<<"x="<<x<<" "<"y="<<y<<endl;} void show( )const{cout<<"x="<A.x=4,y=3;x=7,y=8B.x=3,y=4;x=7,y=8C.x=7,y=8;x=4,y=3D.x=8,y=7;x=7,y=8
有以下程序:include using namespace std;class A{public: A(int i,int j) { a=i; b= 有以下程序: #include <iostream> using namespace std; class A { public: A(int i,int j) { a=i; b=j; } void move(int x,int y) { a+=x; b+=y; } void show() { cout<<a<<","<<b<<end1; } private: int a,b; }; class B: private A { public: B(int i,int j): A(i,j) {} void fun() { move(3,5); } void fl () { A::show(); } }; int main() { B d(3,4); d.fun(); d.f1(); return 0; } 程序执行后的输出结果是A.3,4B.6,8C.6,9D.4,3
有以下程序:include using namespacestd;class A{public:A(int i,int j){ a=1; b=j;} 有以下程序:#include <iostream>using namespace std;class A{public: A(int i,int j) { a=1; b=j; } void move (int x,int y) { a+=x; b+=y; } void show() cout<<a<<","<<b<<end1 } private: int a,b; }; class B : private A { public: B(int i,int 3):A (i,j) {} void fun() { move (3,5); } void f1() { A::show(); } }; int main() { B d(3,4); d.fun(); d.f1(); return 0; } 程序执行后的输出结果是A.3,4B.6,8C.6,9D.4,3
有如下程序: include using namespace std; class TestClass { private: int x,y; pu 有如下程序: #include<iostream> using namespace std; class TestClass { private: int x,y; public: TestClass (int i,int j) { x=i; y=j; } void print() { cout<<"print1"<<end1; } void print()const { cout<<"print2"<<end1; } }; int main() { const TestClass a(1,2); a.print(); return 0; } 该程序运行后的输出结果是( )。A.print1B.print2C.print1 print2D.程序编译时出错
有如下程序:include using namespace std;class sample{private: int x, y;public: s 有如下程序: #include <iostream> using namespace std; class sample { private: int x, y; public: sample(int i,int j) { x=i; y=j; } void disp() { cout<<"displ"<<end1; } void disp() const { cout<<"disp2"<<end1; } }; int main () { const sample a(i,2); a.disp (); return 0; } 该程序运行后的输出结果是( )。A.disp1B.disp2C.disp1 disp2D.程序编译时出错
有以下程序: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
若有以下程序include using namespace std;class A{public: A(int i,int j) {a=i;b=j 若有以下程序 #include <iostream> using namespace std; class A { public: A(int i,int j) { a=i; b=j; } void move(int x, int y) { a+=x; b+=y; } void show() { cout < <a < <" , " <<b<< end1; } private: int a,b; }; class B : private A { public: B(int i,int j) :A(i,j) {} void fun ( ) { move (3, 5); } void f1 ( ) { A::show(); } }; int main ( ) { B d(3,4); d. fun ( ); d.f1(); return 0; } 程序执行后的输出结果是 ( )。A.3,4B.6,8C.6,9D.4,3
有以下程序:include using namespace std;class sample{private: int x;public: void 有以下程序: #include <iostream> using namespace std; class sample { private: int x; public: void setx(int i) { x=i; } int putx () { return x; } }; int main ( ) { sample *p; sample A[3]; A[0] .setx(5); A[1] .setx (6); A[2] .setx(7); for (int j=0;j<3;j++) { p=A[j]; cout<<p->putx () <<", "; } cout<<end1; return 0; } 执行后执行结果是( )。A.5,6,7,B.5,5,5,C.6,6,6,D.7,7,7,
有下列程序:includeusing namespace std;class TestClass{private:int x,y;public:Te 有下列程序: #include<iostream> using namespace std; class TestClass { private: int x,y; public: TestClass (int i,int j) { x=i; y=j; } void print() { cout<<"printl"<<endl; } voA.print1B.print2C.pfint1 print2D.程序编译时出错
若有以下程序:includeusing namespace std;class A{public:A(int i,int j){a=i;b=j;} 若有以下程序: #include<iostream> using namespace std; class A { public: A(int i,int j) { a=i; b=j; } void move(int x,int y) { a+=x; b+=y; } void show() { cout<<a<<","<<b<<endl; } private: int a,b; }; class B:private A { public: B(int i,int j):A(i,j){} void fun() { move(3,5); } void fl() { A::show(); } }; int main() { B d(3,4); d.fun(); d.fl(); return 0; } 程序执行后的输出结果是( )。A.3,4B.6,8C.6,9D.4,3
有以下程序: #include 〈iostream〉 using namespace std; class A { public: virtual void setx(int i,int j=0) { x=i; y=j; } virtual void print()=0; protected: int x,y; }; class B : public A { public: void print() { cout〈〈x*x〈〈", "; } }; class C : public A { public: void print() { cout〈〈x*x*x〈〈end1; } }; int main() { A *pa; B b; C c; pa=b; pa-setx(5); pa-print (); pa=c; pa-setx(2); pa-print(); return 0; } 程序运行后的输出结果是( )。A.25,8B.2,5C.5,2D.8,25
有以下程序:include using namespace std;class B{private: int a,b;public: B(){} B 有以下程序: #include <iostream> using namespace std; class B { private: int a,b; public: B(){} B(int i,int j); void printb(); }; class A { B C; public: A(){} A(int i,int j); void printa(); }; A::A(int i,int j) :c(i,j) {} void A::printa() { c.printb (); } B::B(int i, int j) { a=i; b=j; } void B: :printb() { cout<<a<<", "<<b<<end1; } int main () { A m(7,8); m.printa(); return 0; } 该程序运行后的输出结果是( )。A.5,6B.7,8C.8,9D.9,10
若有如下程序:includeusing namespace std;class A{public:A(int i,int j){a=i;b=j;} 若有如下程序: #include<iostream> using namespace std; class A { public: A(int i,int j) { a=i; b=j; } void move(int x,int y) { a+=x; b+=y; } void show() { cout<<a<<","<<b<<end1; } private: int a,b; }; class B:private A { public: B(int i,int j):A(i,j) { } void fun() { move(3,5); } void f1() { A::show(); } }; int main() { B d(3,4); d.fun(); d.f1(); return 0; } 程序执行后的输出结果是( )。A.3,4B.6,8C.6,9D.4,3
下列程序的输出结果是includeclass Myclass{ public:My class(inti=0,int j=0) {x= 下列程序的输出结果是 #include<iostream.h> class Myclass{ public:My class(inti=0,int j=0) { x=i; y=j; } void show(){cout<<"x=" <<x<<" " <"y=" <<y<<endl;} void show()const{cout<<"x="<<""<<"y="<<y<<endl;} privated: int x; int y; }; void main() { Myclassmy1(3,4); const my2(7,8); myl.show();my2.show();}A.x=4,y=3;x=7,y=8B.x=3,y=4;X=7,y=8C.x=7,y=8;x=4,y=3D.x=8,y=7;x=7,y=8
下列程序的输出结果是______。 include class base { int x,y; public: base(int i,i 下列程序的输出结果是______。include<iostream.h>class base{int x,y;public:base(int i,int j){x=i;y=j;}virtual int add( ){return x+y;}};class three:public base{int z;public:three(int i,int j,int k):base(i,j){z=k;)int add( ){return(base::add( )+z);}};void main( ){three*q=new three(10,20,30);cout<<q->add( )<<endl;}
现有: public class TestDemo{ private int X-2; static int y=3; public void method(){ final int i=100; int j =10; class Cinner { public void mymethod(){ //Here } } } } 在Here处可以访问的变量是哪些?() A、XB、yC、jD、i
public class TestDemo{ private int x = 2; static int y = 3; public void method(){ final int i=100; int j = 10; class Cinner{ public void mymethod(){ //Here } } } } 在Here处可以访问的变量是哪些?()A、xB、yC、iD、j
多选题现有: public class TestDemo{ private int X-2; static int y=3; public void method(){ final int i=100; int j =10; class Cinner { public void mymethod(){ //Here } } } } 在Here处可以访问的变量是哪些?()AXByCjDi
多选题public class TestDemo{ private int x = 2; static int y = 3; public void method(){ final int i=100; int j = 10; class Cinner{ public void mymethod(){ //Here } } } } 在Here处可以访问的变量是哪些?()AxByCiDj