看看这些C++程序运行的结果是什么?在线等。急!!!谢谢啦
1.写出下列程序的运行结果#include<iostream.h>inti=15;voidmain(){inti;i=100;::i=i+1;cout<<::i<<end...
1. 写出下列程序的运行结果
#include <iostream.h>
int i=15;
void main()
{
int i;
i=100;
::i=i+1;
cout<<::i<<endl;
}
2. 写出下列程序的运行结果
class Person{
public:
Person(){cout<< “Constructor of Person”<<endl;}
~Person(){cout<< “Destructor of Person”<<endl;}
};
class Student:public Person{
public:
Student(){cout<< “Constructor of Student”<<endl;}
~Student(){cout<< “Destructor of Student”<<endl;}
};
class Teacher:public Person{
public:
Teacher(){cout<< “Constructor of Teacher”<<endl;}
~Teacher(){cout<< “Destructor of Teacher”<<endl;}
};
void main()
{
Student s;
Teacher t;
}
3. 写出下列程序的运行结果。
#include <iostream.h>
int square(int i) {return i*i;}
float square(float i) {return i*i;}
double square(double i) {return i*i;}
int main()
{ int i=12;
float f=3.0;
double d=5.0;
cout<<i<<'*'<<i<<'='<<square(i)<<'\n';
cout<<f<<'*'<<f<<'='<<square(f)<<'\n';
cout<<d<<'*'<<d<<'='<<square(d)<<'\n';
return 0;
}
4. 写出下面程序运行的结果。
#include <iostream.h>
class B{
public:
B(){cout<< “class B”<<endl;}
};
class X:virtual public B
{
public:
X(){cout<< “class X”<<endl;}
};
class Y:virtual public B
{
public:
Y(){cout<< “class Y”<<endl;}
};
class D:public X,public Y
{
public:
D(){cout<< “class D”<<endl;}
};
void main()
{ D obj; }
5. 写出下面程序运行的结果。
#include <iostream.h>
int main()
{
int *p;
p=new int(99);
cout<<*p++;
delete --p;
return 0;
}
我也想啊,不知道为什么我的VC++出毛病了。。。麻烦大哥们帮我把另外一个提问也搞定了吧,谢谢啦。还有6-10的。 展开
#include <iostream.h>
int i=15;
void main()
{
int i;
i=100;
::i=i+1;
cout<<::i<<endl;
}
2. 写出下列程序的运行结果
class Person{
public:
Person(){cout<< “Constructor of Person”<<endl;}
~Person(){cout<< “Destructor of Person”<<endl;}
};
class Student:public Person{
public:
Student(){cout<< “Constructor of Student”<<endl;}
~Student(){cout<< “Destructor of Student”<<endl;}
};
class Teacher:public Person{
public:
Teacher(){cout<< “Constructor of Teacher”<<endl;}
~Teacher(){cout<< “Destructor of Teacher”<<endl;}
};
void main()
{
Student s;
Teacher t;
}
3. 写出下列程序的运行结果。
#include <iostream.h>
int square(int i) {return i*i;}
float square(float i) {return i*i;}
double square(double i) {return i*i;}
int main()
{ int i=12;
float f=3.0;
double d=5.0;
cout<<i<<'*'<<i<<'='<<square(i)<<'\n';
cout<<f<<'*'<<f<<'='<<square(f)<<'\n';
cout<<d<<'*'<<d<<'='<<square(d)<<'\n';
return 0;
}
4. 写出下面程序运行的结果。
#include <iostream.h>
class B{
public:
B(){cout<< “class B”<<endl;}
};
class X:virtual public B
{
public:
X(){cout<< “class X”<<endl;}
};
class Y:virtual public B
{
public:
Y(){cout<< “class Y”<<endl;}
};
class D:public X,public Y
{
public:
D(){cout<< “class D”<<endl;}
};
void main()
{ D obj; }
5. 写出下面程序运行的结果。
#include <iostream.h>
int main()
{
int *p;
p=new int(99);
cout<<*p++;
delete --p;
return 0;
}
我也想啊,不知道为什么我的VC++出毛病了。。。麻烦大哥们帮我把另外一个提问也搞定了吧,谢谢啦。还有6-10的。 展开
3个回答
展开全部
实在没有什么技术含量!
1)
101
2)
Constructor of Person
Constructor of Student
Constructor of Person
Constructor of Teacher
Destructor of Teacher
Destructor of Person
Destructor of Student
Destructor of Person
3)
12*12=144
3*3=9
5*5=25
4)
class B
class X
class Y
class D
5)
99
1)
101
2)
Constructor of Person
Constructor of Student
Constructor of Person
Constructor of Teacher
Destructor of Teacher
Destructor of Person
Destructor of Student
Destructor of Person
3)
12*12=144
3*3=9
5*5=25
4)
class B
class X
class Y
class D
5)
99
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
老大,你拿编译器,搞一下不就知道了。我很久不用C++编译器了。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
1) 101
2)
Constructor of Person
Constructor of Student
Constructor of Person
Constructor of Teacher
Destructor of Teacher
Destructor of Person
Destructor of Student
Destructor of Person
3)
12*12=144
3*3=9
5*5=25
4)
class B
class X
class Y
class D
5)
99
2)
Constructor of Person
Constructor of Student
Constructor of Person
Constructor of Teacher
Destructor of Teacher
Destructor of Person
Destructor of Student
Destructor of Person
3)
12*12=144
3*3=9
5*5=25
4)
class B
class X
class Y
class D
5)
99
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询