阅读下列程序,程序的运行结果是____。
#include
usingnamespacestd;
classAnimal
{
public:
voidspeak(){cout<<"animallanguage!"<};
classCat:publicAnimal
{
public:
voidspeak(){cout<<"catlanguage:miaomiao!"<};
intmain()
{
Catcat;
cat.speak();
}
#include
usingnamespacestd;
classAnimal
{
public:
voidspeak(){cout<<"animallanguage!"<
classCat:publicAnimal
{
public:
voidspeak(){cout<<"catlanguage:miaomiao!"<
intmain()
{
Catcat;
cat.speak();
}
举一反三
- 给出下面程序的运行结果 #include usingnamespacestd; intmain { cout<<"This"<<""<<"is"<<""; cout<<"a"<<""<<"C++"<<""; cout<<"program."<<endl; return0; }
- #分析下面程序运行的结果。 #include usingnamespacestd; intmain { cout<<"This"<<"is"; cout<<"a"<<"C++"; cout<<"program."<<endl; return0; }#
- 下列程序的运行结果是:#include<iostream>usingnamespacestd;intmain(){inta=2;intb=a+1;cout<<a/b<<endl;return0;}
- 写出程序运行结果:_________ #include <iostream.h> class Bas { public: ~Bas() { cout<<"Bas construct"<<endl; } virtual void f()=0; }; class Dev:public Bas { public: ~Dev() { cout<<"Bas construct"<<endl; } virtual void f() { cout<<"Dev::f"<<endl; } }; void main() { Bas *a; Dev p; a=&p; a->f(); }
- 阅读下列程序,写出运行结果。 #include [iostream] using namespace std; int main() { int a = 1, b = 2; bool x, y; cout [< (a++)+(++b) << endl; cout << a % b << endl; x = !a]b; y = a-- && b; cout << x << endl; cout << y << endl; }