[单选题]

有以下程序include include using namespace std;class base{private:char

有以下程序 #include <iostream> #include <string> using namespace std; class base { private: char baseName[10]; public: base () { strcpy(baseName,"Base"); } virtual char *myName() { return baseName; } char *className() { return baseName; } }; class Derived : public base { private: char derivedName[10]; public: Derived() { strcpy(derivedName,"Derived"); } char *myName() { return derivedName; } char *className() { return derivedName; } }; void showPtr(base &p) { cout<<p.myName () <<" "<<p.className (); } int main () { base bb; Derived dd; showPtr(dd); return 0; } 运行后的输出结果为

A.Derived Base

B.Base Base

C.Derived Derived

D.Base Derived

参考答案与解析:

相关试题

有以下程序:#include #include using namespace

[单选题]有以下程序:include include using namespace std;int main ( ){ char b1[8有以下程序: #include <iostream> #include <string> using namespace std; int main ( ) { char b1[8] = "abcdefg"; char b2[8],*pb=b1+3; while (--pb>=b1) strcpy (b2, Pb) ; cout<<strlen (b2) <<en

  • 查看答案
  • 有以下程序:#include #include using namespace

    [单选题]有以下程序:include include using namespace std;class point{private: doub有以下程序: #include <iostream> #include <math> using namespace std; class point { private: double x; double y; public: point(double a,double b) { x=a; y=b; } friend double distance(point

  • 查看答案
  • 有以下程序:#include #include using namespace

    [单选题]有以下程序:include include using namespace std;class Y;class X{private有以下程序: #include <iostream> #include <string> using namespace std; class Y; class X { private: int x; char *strx; public: X(int a, char *str) { x=a; strx=new char[strlen(str)+1]; strcpy(

  • 查看答案
  • 有以下程序:#include #include using namespace

    [单选题]有以下程序:include include using namespace std;int main ( ){ ofstream有以下程序: #include <iostream> #include <fstream> using namespace std; int main ( ) { ofstream ofile; char ch; ofile.open ("abc.txt"); cin>>ch; while (ch!='#' ) { cin>>ch; ofile.put(ch);

  • 查看答案
  • 有以下程序:#include #include using namespace

    [单选题]有以下程序:include include using namespace std;class base{private: cha有以下程序: #include <iostream> #include <string> using namespace std; class base { private: char baseName[10]; public: base ( ) { strcpy (baseName, "Base"); } virtual char *myName() {A.De

  • 查看答案
  • 有以下程序:#include #include using namespace

    [单选题]有以下程序:include include using namespace std;class point{private:doubl有以下程序:#include <iostream>#include <math>using namespace std;class point{private: double x; double y;public: point(double a, double b { x=a; y=b; friend double distance (point a, point

  • 查看答案
  • 有以下程序: #include #include using namespace

    [单选题]有以下程序: include include using namespace std; int main() {char arr[有以下程序: #include<iostream> #include<string> using namespace std; int main() { char arr[2][4]; strcpy(arr[0],"you"); strcpy(arr[1],"me"); arr[0][3]='&'; cout<<arr[0]<<end1; retu

  • 查看答案
  • 有以下程序:#include using namespace std;int s

    [单选题]有以下程序:include using namespace std;int s=0;class sample{ static int n;publi有以下程序: #include <iostream> using namespace std; int s=0; class sample { static int n; public: sample (int i) { n=i; } static void add() { s+=n; } }; int sample::n=0;A.2B.5C.7D.

  • 查看答案
  • 有如下程序#include #include using namespace s

    [单选题]有如下程序include include using namespace std;class MyClass {public:M有如下程序#include <iostream>#include <iomanip>using namespace std; class MyClass {public:MyClass(){ cout<<'A'; }MyClass(char c){ cout<<c; }~MyClass(){ cout<<'B'; }};int main() {MyClass p

  • 查看答案
  • 有如下程序#include #include using namespace s

    [单选题]有如下程序include include using namespace std;int main( ){cout<

  • 查看答案
  • 有以下程序#include #include using namespace s