摘要: 声明复数类Complex,该类中有两个私有变量real , image分别表示一个复数的实部和虚部。 为Complex类添加适当的构造函数,并使用友元函数 add实现复数加法。 #include <iostream>using namespace std; class Complex{private 阅读全文
posted @ 2022-03-20 15:12 bobo哥 阅读(100) 评论(0) 推荐(0)
摘要: 源程序: #include <iostream>using namespace std; class Based{public: Based() { cout<<"Based构造函数\n"; fun(); } virtual void fun() { cout<<"Base::fun()函数\n"; 阅读全文
posted @ 2022-03-20 14:58 bobo哥 阅读(65) 评论(0) 推荐(0)
摘要: 源程序: #include <iostream>using namespace std; class example{private: int a;public: example(int b=5) { a=b++; } void print() { a=a+1; cout<<a<<" "; } vo 阅读全文
posted @ 2022-03-20 14:49 bobo哥 阅读(71) 评论(0) 推荐(0)
摘要: 源程序: 要求输出结果为40 #include <iostream>using namespace std; class Test{ static int x; //程序填空public: Test(int i=0) { x=i+x; } int Getnum() { return Test::x+ 阅读全文
posted @ 2022-03-20 11:47 bobo哥 阅读(54) 评论(0) 推荐(0)
摘要: 源程序: #include <iostream>using namespace std; class line;class box{private: int color; int upx,upy; int lowx,lowy;public: friend int same_color(line l, 阅读全文
posted @ 2022-03-20 11:40 bobo哥 阅读(44) 评论(0) 推荐(0)
摘要: 源程序: 下列程序,输出结果为150。 #include <iostream>using namespace std; class Arr{ int *a,n;public: Arr():a(0),n(0){} Arr(int *aa,int nn) { n=nn; a=new int [n]; f 阅读全文
posted @ 2022-03-20 11:16 bobo哥 阅读(53) 评论(0) 推荐(0)