摘要: 源程序: #include <iostream>using namespace std; class Base{public: virtual void fun() { cout << "Base::fun()" << endl; }}; class Derived :public Base{pub 阅读全文
posted @ 2020-02-04 23:13 bobo哥 阅读(157) 评论(0) 推荐(0)
摘要: 源程序: #include <iostream>using namespace std; class A{public: int i; virtual void func() { cout << "A0" << endl; } virtual void func2() { cout << "A1" 阅读全文
posted @ 2020-02-04 23:05 bobo哥 阅读(120) 评论(0) 推荐(0)
摘要: 源程序: #include <iostream>using namespace std; class Base{public: virtual void display() = 0; };class Derived1 :public Base{public: void display() { cou 阅读全文
posted @ 2020-02-04 22:58 bobo哥 阅读(144) 评论(0) 推荐(0)
摘要: 源程序: #include <iostream>using namespace std; class Bas{public: ~Bas() { cout << "Bas析构函数" << endl; } virtual void f() = 0;}; class Dev :public Bas{pub 阅读全文
posted @ 2020-02-04 22:47 bobo哥 阅读(217) 评论(0) 推荐(0)
摘要: 源程序: #include <iostream>using namespace std; class A{public: int i; virtual void func() { cout << "A0" << endl; } virtual void func2() { cout << "A1" 阅读全文
posted @ 2020-02-04 21:48 bobo哥 阅读(153) 评论(0) 推荐(0)
摘要: 源程序: #include <iostream>using namespace std; class CBase{protected: int n;public: CBase(int i) :n(i) {} void Print() { cout << "CBase:n=" << n << endl 阅读全文
posted @ 2020-02-04 21:30 bobo哥 阅读(213) 评论(0) 推荐(0)
摘要: 源程序: #include <iostream>using namespace std; class base{ int a;public: base(int sa) { a = sa; } int geta() { return a; }}; class derived :public base{ 阅读全文
posted @ 2020-02-04 21:15 bobo哥 阅读(192) 评论(0) 推荐(0)
摘要: 源程序: #include <iostream>using namespace std;class B{private: int data;public: B() { cout << "构造函数B" << endl; } B(int a) { data = a; cout << "带1个参数的构造函 阅读全文
posted @ 2020-02-04 21:06 bobo哥 阅读(128) 评论(0) 推荐(0)
摘要: 源程序: #include<iostream>using namespace std; class BaseClass1{protected: int v1, v2;public: BaseClass1(); BaseClass1(int, int); ~BaseClass1(); void Set 阅读全文
posted @ 2020-02-04 20:25 bobo哥 阅读(145) 评论(0) 推荐(0)
摘要: 源程序: #include <iostream>#include <string>using namespace std;class Date{public: Date(int y, int m, int d) { SetDate(y,m,d); } void SetDate(int y, int 阅读全文
posted @ 2020-02-04 20:17 bobo哥 阅读(174) 评论(0) 推荐(0)
摘要: 源程序: #include <iostream>using namespace std; class Base{private: int radius, width;public: Base() { cout << "Base默认构造函数" << endl; } Base(int r, int w) 阅读全文
posted @ 2020-02-04 19:53 bobo哥 阅读(146) 评论(0) 推荐(0)
摘要: 源程序: #include <iostream>using namespace std; class vehicle{public: int wheels; float weight;public: vehicle(int wheels1, float weight1) { wheels = whe 阅读全文
posted @ 2020-02-04 19:37 bobo哥 阅读(163) 评论(0) 推荐(0)
摘要: 源程序: #include <iostream>using namespace std; class CB{ int b;public: CB(int n) { b = n; cout << "CB::b=" << b << endl; } ~CB() { cout << "CB的对象在消亡" << 阅读全文
posted @ 2020-02-04 18:51 bobo哥 阅读(141) 评论(0) 推荐(0)
摘要: 源程序: #include<iostream>using namespace std; class CBase{protected: int n;public: CBase(int i) :n(i) {} void Print() { cout << "CBase:n=" << n << endl; 阅读全文
posted @ 2020-02-04 18:31 bobo哥 阅读(202) 评论(0) 推荐(0)
摘要: 源程序: #include<iostream>using namespace std; class BaseClass1{protected: int v1, v2;public: BaseClass1(); BaseClass1(int, int); ~BaseClass1();}; BaseCl 阅读全文
posted @ 2020-02-04 18:28 bobo哥 阅读(119) 评论(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; }}; c 阅读全文
posted @ 2020-02-04 18:23 bobo哥 阅读(156) 评论(0) 推荐(0)
摘要: 源程序: //封闭类的构造函数#include<iostream>#include<string>using namespace std; class myDate{public: myDate(); myDate(int); myDate(int, int); myDate(int, int, i 阅读全文
posted @ 2020-02-04 18:14 bobo哥 阅读(148) 评论(0) 推荐(0)
摘要: 源程序: #include<iostream>using namespace std; class BaseClass1{protected: int v1, v2;public: BaseClass1(); BaseClass1(int, int); ~BaseClass1(); void Set 阅读全文
posted @ 2020-02-04 17:58 bobo哥 阅读(117) 评论(0) 推荐(0)
摘要: 源程序: #include<iostream>using namespace std; class CBase{public: CBase() {} CBase(CBase &c) { cout << "CBase::复制构造函数" << endl; } CBase & operator=(cons 阅读全文
posted @ 2020-02-04 17:54 bobo哥 阅读(151) 评论(0) 推荐(0)
摘要: 源程序: #include<iostream>using namespace std; class A{public: A() //默认构造函数 { i = 100; cout << "类A默认构造函数" << endl; } A(const A&s) //复制构造函数 { i = s.i; cou 阅读全文
posted @ 2020-02-04 17:49 bobo哥 阅读(145) 评论(0) 推荐(0)
摘要: 源程序: #include<iostream>using namespace std; class Base{private: int Y;public: Base(int y=0) { Y=y; cout<<"Base("<<y<<")"<<endl; } ~Base() { cout<<"~Ba 阅读全文
posted @ 2020-02-04 17:29 bobo哥 阅读(144) 评论(0) 推荐(0)
摘要: 源程序: #include<iostream>using namespace std; class BaseClass{public: int v1, v2; BaseClass(); BaseClass(int, int); ~BaseClass();};BaseClass::BaseClass( 阅读全文
posted @ 2020-02-04 17:26 bobo哥 阅读(142) 评论(0) 推荐(0)
摘要: 源程序: #include<iostream>#include<string>using namespace std; class A{ int an;public: A() {} A(int n) { an = n; } void print() { cout << "A的对象:"; cout < 阅读全文
posted @ 2020-02-04 16:30 bobo哥 阅读(101) 评论(0) 推荐(0)
摘要: 源程序: #include<iostream>#include<string>using namespace std; class Base{ //基类的3种访问控制类型成员变量public: int vBPub;protected: int vBPro;private: int vBPri;pub 阅读全文
posted @ 2020-02-04 16:23 bobo哥 阅读(123) 评论(0) 推荐(0)
摘要: 源程序: #include<iostream>using namespace std; class BaseClass1{public: int v1, v2; BaseClass1(); BaseClass1(int, int); ~BaseClass1();};BaseClass1::BaseC 阅读全文
posted @ 2020-02-04 16:21 bobo哥 阅读(109) 评论(0) 推荐(0)
摘要: 源程序: #include<iostream>using namespace std; class CB1{public: int a; //重名 CB1(int x) { a=x; } void showa() //重名 { cout<<"Class CB1==>a="<<a<<endl; }}; 阅读全文
posted @ 2020-02-04 16:19 bobo哥 阅读(93) 评论(0) 推荐(0)
摘要: 源程序: #include<iostream>using namespace std; class BaseClass //基类{protected: int v1, v2;public: void SetValue(int m, int n) { v1 = m; v2 = n; } void Pr 阅读全文
posted @ 2020-02-04 16:17 bobo哥 阅读(113) 评论(0) 推荐(0)
摘要: 源程序: #include<iostream>using namespace std; class BaseClass //基类{ int v1, v2;public: void SetValue(int m, int n) { v1 = m; v2 = n; } void PrintValue() 阅读全文
posted @ 2020-02-04 16:13 bobo哥 阅读(122) 评论(0) 推荐(0)
摘要: 源程序: #include<iostream>#include<string>using namespace std; class employee //类employee将作为其他几个类的基类{ short age; float salary;protected: string name;publ 阅读全文
posted @ 2020-02-04 16:11 bobo哥 阅读(186) 评论(0) 推荐(0)
摘要: 源程序: #include<iostream>#include<string>using namespace std; class CStudent //基类{private: string name; //姓名 string id; //学号 char gender; //性别,‘F’代表女生,‘ 阅读全文
posted @ 2020-02-04 16:01 bobo哥 阅读(173) 评论(0) 推荐(0)
摘要: 源程序: #include<iostream>using namespace std; class CB{public: int a; CB(int x) { a=x; } void showa() { cout<<"Class CB --a="<<a<<endl; }}; class CD:pub 阅读全文
posted @ 2020-02-04 15:59 bobo哥 阅读(203) 评论(0) 推荐(0)
摘要: 源程序: #include<iostream>using namespace std; class Base //基类{private: float x;public: static int staV; Base() { staV++; }}; int Base::staV = 0; class D 阅读全文
posted @ 2020-02-04 15:57 bobo哥 阅读(118) 评论(0) 推荐(0)
摘要: 源程序: #include<iostream>using namespace std; class another;class Base{private: float x;public: void print(const another &K);};class Derived:public Base 阅读全文
posted @ 2020-02-04 14:43 bobo哥 阅读(118) 评论(0) 推荐(0)
摘要: 源程序: //基类与子类占用空间及字节对齐#include<iostream>using namespace std; class BaseClass{ int v1,v2; char v4;public: int temp1(){}}; class DerivedClass:public Base 阅读全文
posted @ 2020-02-04 14:41 bobo哥 阅读(100) 评论(0) 推荐(0)
摘要: 源程序: #include<iostream>using namespace std; class CDemo{private: int n;public: CDemo(int i=0):n(i){} CDemo & operator++(); //用于前置形式 CDemo operator++(i 阅读全文
posted @ 2020-02-04 13:35 bobo哥 阅读(184) 评论(0) 推荐(0)
摘要: 源程序: #include<iostream>using namespace std; class CDemo{private: int n;public: CDemo(int i=0):n(i){} CDemo & operator++(); //用于前置形式 CDemo operator++(i 阅读全文
posted @ 2020-02-04 13:32 bobo哥 阅读(171) 评论(0) 推荐(0)
摘要: 源程序: #include<iostream>using namespace std; class myComplex{ double real,imag;public: myComplex(double r=0,double i=0):real(r),imag(i){}; operator dou 阅读全文
posted @ 2020-02-04 13:30 bobo哥 阅读(119) 评论(0) 推荐(0)
摘要: 源程序: #include<iostream>#include<string>#include<cstdlib>using namespace std; class myComplex{private: double real,imag;public: myComplex():real(0),ima 阅读全文
posted @ 2020-02-04 13:27 bobo哥 阅读(130) 评论(0) 推荐(0)
摘要: 源程序: #include<iostream>#include<string>#include<cstdlib>using namespace std; class myComplex{private: double real,imag;public: myComplex():real(0),ima 阅读全文
posted @ 2020-02-04 13:19 bobo哥 阅读(139) 评论(0) 推荐(0)
摘要: 源程序: #include<iostream>using namespace std; class pointer{public: int a; int *p; //指向整型数的指针 pointer() { a=100; p=new int(10); } pointer(const pointer 阅读全文
posted @ 2020-02-04 12:56 bobo哥 阅读(138) 评论(0) 推荐(0)
摘要: 源程序: #include<iostream>using namespace std; class pointer{public: int a; int *p; //指向整型数的指针 pointer() { a=100; p=new int(10); } pointer(const pointer 阅读全文
posted @ 2020-02-04 12:54 bobo哥 阅读(131) 评论(0) 推荐(0)
摘要: 源程序: #include <iostream>#include<string>using namespace std; class myComplex{private: double real, imag;public: myComplex(); myComplex(double r, doubl 阅读全文
posted @ 2020-02-04 12:46 bobo哥 阅读(121) 评论(0) 推荐(0)