上一页 1 ··· 27 28 29 30 31 32 33 34 35 ··· 54 下一页
摘要: 源程序: #include <iostream> using namespace std; int main() { int x, count, sum = 0; freopen("c:\\input.txt", "r", stdin); for (count = 0; count<10; coun 阅读全文
posted @ 2020-01-27 12:44 bobo哥 阅读(104) 评论(0) 推荐(0)
摘要: 源程序: #include <iostream> using namespace std; int main() { int x, count, sum = 0; freopen("c:\\input.txt", "r", stdin); //将标准输入重定向到文件input.txt for (co 阅读全文
posted @ 2020-01-27 12:37 bobo哥 阅读(160) 评论(0) 推荐(0)
摘要: 源程序: #include <iostream> using namespace std; int main() { int x, y; cin >> x >> y; freopen("c:\\test.txt", "w", stdout); if (y == 0) cerr<<"error."<< 阅读全文
posted @ 2020-01-27 12:09 bobo哥 阅读(114) 评论(0) 推荐(0)
摘要: 基类与派生类之间的互相转换,使用指针的情况 源程序: #include<iostream> using namespace std; class CBase { protected: int n; public: CBase(int i):n(i){} void Print() { cout<<"C 阅读全文
posted @ 2020-01-12 19:16 bobo哥 阅读(246) 评论(0) 推荐(0)
摘要: 派生类中的复制构造函数 源程序: #include<iostream> using namespace std; class A { public: A() //默认构造函数 { i=100; cout<<"类A默认构造函数"<<endl; } A(const A&s) //复制构造函数 { i=s 阅读全文
posted @ 2020-01-12 19:03 bobo哥 阅读(173) 评论(0) 推荐(0)
摘要: 互包含的类 源程序: #include<iostream> #include<string> using namespace std; class B; class A { public: int aInt; B *bPoint=NULL; void SetValue(int v) { aInt=v 阅读全文
posted @ 2020-01-12 18:58 bobo哥 阅读(138) 评论(0) 推荐(0)
摘要: 虚基类 源程序: #include <iostream> using namespace std; class A{ public: int a; void showa(){ cout<<"a="<<a<<endl; } }; class B:virtual public A{ public: in 阅读全文
posted @ 2020-01-12 18:23 bobo哥 阅读(131) 评论(0) 推荐(0)
摘要: 抽象类示例 源程序: #include <iostream> using namespace std; class A{ private: int a; public: virtual void print()=0; void func1(){ cout<<"func1"<<endl; } }; c 阅读全文
posted @ 2020-01-12 18:19 bobo哥 阅读(176) 评论(0) 推荐(0)
摘要: 不使用虚析构函数的情况 源程序: #include <iostream> using namespace std; class ABase{ public: ABase(){ cout<<"ABase构造函数"<<endl; } ~ABase(){ cout<<"ABase::析构函数"<<endl 阅读全文
posted @ 2020-01-12 18:10 bobo哥 阅读(206) 评论(0) 推荐(0)
摘要: 多态与非多态的比较 源程序: #include <iostream> using namespace std; class A{ public: void func1(){ cout<<"A::func1"<<endl; } virtual void func2(){ cout<<"A::func2 阅读全文
posted @ 2020-01-12 18:06 bobo哥 阅读(203) 评论(0) 推荐(0)
上一页 1 ··· 27 28 29 30 31 32 33 34 35 ··· 54 下一页