下面程序有注释的语句中,错误的语句是( )。 include using namespace std;下面程序有注释的语句中,错误的语句是( )。 #include <iostream> using namespace std; class A{ int a; public: void show A(){cout<<"this is A!";} }; class B:public A{ int b; public: void show B(){cout<< "this is B!";} }; void

题目
下面程序有注释的语句中,错误的语句是( )。 include using namespace std;

下面程序有注释的语句中,错误的语句是( )。 #include <iostream> using namespace std; class A{ int a; public: void show A(){cout<<"this is A!";} }; class B:public A{ int b; public: void show B(){cout<< "this is B!";} }; void main(){ A ia,*piA; B ib,*piB; piA=ia; //第一个测试语句 piA=&ib; //第二个测试语句 piA->showA(); //第三个测试语句 piA->showB(); //第四个测试语句 }

A.第一个测试语句

B.第二个测试语句

C.第三个测试语句

D.第四个测试语句


相似考题
更多“下面程序有注释的语句中,错误的语句是( )。 #include <iostream> using namespace std; ”相关问题
  • 第1题:

    下面程序错误的语句是 #include" iostream.h" ① void main( ) ② { ③ int A=0; ④ int & B; ⑤ B=A; ⑥ cout < < B; ⑦ cout < < A; ⑧ }

    A.②

    B.③

    C.④

    D.⑥


    正确答案:C
    解析:引用必须在第一时间进行赋值,int&B没有在第一时间赋值故错误。注意:引用的方式,引用和指针应用的比较。

  • 第2题:

    设有如下定义 struct ss { char name[10]; int age; char sex; }std[3], * p=std; 下面各输入语句中错误的是

    A.cin>>(* p).age);

    B.cin>>std.name);

    C.cin>>std[0].sex);

    D.cin>>(p->.sex));


    正确答案:B
    解析:std是一个数组,其内可以存放三个结构体类型的数据。当std单独使用的时候表示一个指针,指向该数组首地址。因此不能直接用std和点操作符进行配对使用。指针操作符->只能和指针配对使用,点操作符只能和有名对象或变量配对使用。

  • 第3题:

    9、有以下说明和定义语句,下面各输入语句中错误的是 #include <stdio.h> int main() { struct student { int age; char sex; char name[8]; }; struct student std; struct student *p=&std; ....... return 0; }

    A.scanf("%c",&std[0].sex);

    B.scanf("%d",&(*p).age);

    C.scanf("%s",std.name);

    D.scanf("%c",&(p->sex));


    C

  • 第4题:

    下面程序错误的语句是 #include"iostream.h" ① void main() ② { ③ int A=0; ④ int & B; ⑤ B=A ⑥ cout<<B; ⑦ cout<<A; ⑧ }

    A.②

    B.③

    C.④

    D.⑥


    正确答案:C
    解析:引用必须在第一时间进行赋值,int&B没有在第一时间赋值故错误。注意:引用的方式,引用和指针应用的比较。

  • 第5题:

    下面程序错误的语句是①include ②void main()③{④int * p=new int[1]⑤p=9⑥cout<<* p<

    下面程序错误的语句是

    ①#include<iostream.h>

    ②void main()

    ③{

    ④ int * p=new int[1]

    ⑤ p=9

    ⑥ cout<<* p<<end1;

    ⑦ delete []p;

    ⑧}

    A.④

    B.⑤

    C.⑥

    D.⑦


    正确答案:B
    解析:本题考查的是指针的使用,p是指向int型的指针,若想给它指向的元素赋值,应使用*符号,直接赋值相当于改变了原来p存储的地址。