02 2020 档案

摘要:源程序: #include <iostream>#include <cmath>#define PI 3.1415926using namespace std; class Geometry{public: Geometry() {}; ~Geometry() {}; virtual double 阅读全文
posted @ 2020-02-08 15:14 bobo哥 阅读(185) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>#include <string>#include <cstdlib>using namespace std;class point{private: double x, y;public: point() {}; point(double a, do 阅读全文
posted @ 2020-02-08 11:20 bobo哥 阅读(181) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>#include <iomanip>using namespace std; class myComplex{private: double real, imag;public: myComplex(); myComplex(double r,doub 阅读全文
posted @ 2020-02-08 10:37 bobo哥 阅读(178) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>using namespace std; class pointer{public: int a; int *p; pointer() { a = 100; p = new int(10); } pointer(const pointer &tempp 阅读全文
posted @ 2020-02-08 09:31 bobo哥 阅读(162) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>using namespace std; class pointer{public: int a; int *p; pointer() { a = 100; p = new int(10); } pointer(const pointer &tempp 阅读全文
posted @ 2020-02-08 09:22 bobo哥 阅读(171) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>using namespace std; class myComplex{public: int real, imag; myComplex(int r = 0, int i = 0) { real = r; imag = i; }};myComple 阅读全文
posted @ 2020-02-08 09:15 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) {} ope 阅读全文
posted @ 2020-02-08 09:04 bobo哥 阅读(145) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream> using namespace std;class Point {public: Point(int x = 0, int y = 0) :x(x), y(y) { count++; } Point(Point&p) { x = p.x; y = p 阅读全文
posted @ 2020-02-06 21:09 bobo哥 阅读(201) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>#include <cmath>using namespace std; class Point{private: double x, y;public: Point() {}; Point(double a, double b) { x = a; y 阅读全文
posted @ 2020-02-06 20:48 bobo哥 阅读(176) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>using namespace std;class Location{public: int x, y; void init(int initx,int inity); int Getx(); int Gety();};void Location::i 阅读全文
posted @ 2020-02-06 20:23 bobo哥 阅读(205) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>using namespace std;class exa{ int a;public: exa(int b = 5) { a = b++; } void print() { a = a + 1; cout << a << " "; } void pr 阅读全文
posted @ 2020-02-06 20:16 bobo哥 阅读(128) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>using namespace std; class CTest{private: int n;public: CTest() { n = 1; } int GetValue() const { return n; } int GetValue() { 阅读全文
posted @ 2020-02-06 20:12 bobo哥 阅读(141) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>using namespace std; class base{private: int m;public: base() {}; base(int a) :m(a) {} int get() { return m; } void set(int a) 阅读全文
posted @ 2020-02-06 20:04 bobo哥 阅读(144) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>using namespace std; class A{ int a, b;public: A(int x = 0, int y = 0) { a = x; b = y; }};int main(){ A *p; p = new A(4,5); sy 阅读全文
posted @ 2020-02-06 19:57 bobo哥 阅读(141) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>using namespace std;class f{private: int x, y;public: void f1() { x = 10; y = 10; } void print() { cout << x << "," << y << en 阅读全文
posted @ 2020-02-06 19:52 bobo哥 阅读(137) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>using namespace std; class Test{private: static int num;public: Test(int); void show();};int Test::num = 5;Test::Test(int n){ 阅读全文
posted @ 2020-02-06 19:48 bobo哥 阅读(154) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>using namespace std; class Aton{public: int X, Y; int zx, zy; void init(int i, int j) { zx = i; zy = j; } Aton(int i, int j, i 阅读全文
posted @ 2020-02-06 19:39 bobo哥 阅读(125) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>using namespace std; class point{private: float x, y;public: void f1(float a, float b) { x = a; y = b; } point() { x = 0; y = 阅读全文
posted @ 2020-02-06 19:28 bobo哥 阅读(170) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>using namespace std;class point{private: float x;public: void f(float a) { x = a; } void f() { x = 0; } friend float max(point 阅读全文
posted @ 2020-02-06 19:20 bobo哥 阅读(126) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>#define PI 3.1415926using namespace std; class Cylinder{private: double r, h;public: Cylinder(double rr, double hh) { r = rr; 阅读全文
posted @ 2020-02-06 18:59 bobo哥 阅读(125) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>#include <math.h>using namespace std;class Point{private: float x, y;public: Point(float a, float b); float getX(); float getY 阅读全文
posted @ 2020-02-06 18:35 bobo哥 阅读(112) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>#include <cmath>using namespace std; class Point{private: double x, y;public: Point(double a, double b) { x = a; y = b; } doub 阅读全文
posted @ 2020-02-06 16:27 bobo哥 阅读(148) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>#include <string>using namespace std; class Course{private: string coursename; int credit; int xueshi; string type; string pro 阅读全文
posted @ 2020-02-06 15:48 bobo哥 阅读(189) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>using namespace std;class MyClassType1{private: int x, y;public: int getx() { return x; } int gety(); void setx(int x0) { x = 阅读全文
posted @ 2020-02-06 15:10 bobo哥 阅读(158) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>using namespace std;class Test{ int a, b; int getmin() { return (a < b) ? a : b; }public: int c; void setValue(int x1, int x2, 阅读全文
posted @ 2020-02-06 14:58 bobo哥 阅读(133) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>using namespace std; int main(){ int *p1; int **p2 = &p1; int b = 20; p1 = &b; cout << **p2 << endl; system("pause"); return 1 阅读全文
posted @ 2020-02-06 14:53 bobo哥 阅读(113) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>using namespace std;class A{public: int a, b;private: int c, d;public: int getc();};int A::getc(){ return c;}int main(){ A one 阅读全文
posted @ 2020-02-06 14:50 bobo哥 阅读(144) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>using namespace std; class Test{ int x, y;public: void fun(int i, int j) { x = i; y = j; } void show() { cout << "x=" << x; if 阅读全文
posted @ 2020-02-06 14:42 bobo哥 阅读(122) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>using namespace std;class Test{private: int x, y;public: Test(int i, int j) { x = i; y = j; } int getx() { return x; } int get 阅读全文
posted @ 2020-02-06 14:37 bobo哥 阅读(150) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>using namespace std;int bigger(int x, int y){ if (x > y) return x; else return y;} float bigger(float x, float y){ if (x > y) 阅读全文
posted @ 2020-02-06 14:25 bobo哥 阅读(121) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>#include <cmath>using namespace std; int f(int);int main(){ int i; for (i = 0; i < 3; i++) cout << f(i) << endl; system("pause 阅读全文
posted @ 2020-02-06 14:19 bobo哥 阅读(135) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>using namespace std;int main(){ int oneInt = 1; int &ref = oneInt; ref = 2; cout << "oneInt=" << oneInt << "," << "ref=" << re 阅读全文
posted @ 2020-02-06 14:15 bobo哥 阅读(133) 评论(0) 推荐(1) 编辑
摘要:源程序: #include <iostream>using namespace std;class A{public: int fun(double); int fun(int);};int A::fun(double x){ return (int)x / 2;} int A::fun(int x 阅读全文
posted @ 2020-02-06 14:10 bobo哥 阅读(127) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>using namespace std; const double pi = 3.14159;int main(){ double r; cout << "输入r:"; cin >> r; double l = 2.0*pi*r; double s = 阅读全文
posted @ 2020-02-06 14:05 bobo哥 阅读(203) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>using namespace std;int main(){ const int x = 5, y = 6; const int *p = &x; p = const_cast<int *>(&y); cout << *p << endl; syst 阅读全文
posted @ 2020-02-06 14:00 bobo哥 阅读(118) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>using namespace std;void func(int a, int b, int c = 0){ cout << a << b << c << endl;}int main(){ func(5,9); system("pause"); r 阅读全文
posted @ 2020-02-06 13:57 bobo哥 阅读(128) 评论(0) 推荐(0) 编辑
摘要:源程序:用面向对象方法又做一遍 #include <iostream>#define N 10using namespace std; template <typename T> class sum_array{private: T a[N];public: sum_array(T a1[]) { 阅读全文
posted @ 2020-02-06 10:07 bobo哥 阅读(158) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>#define N 10using namespace std; template <typename T> T sum_array(T a[], int n){ int i,size; T sum=0; cout << "您想求数组前几项的和,请输入 阅读全文
posted @ 2020-02-06 09:53 bobo哥 阅读(139) 评论(0) 推荐(0) 编辑
摘要:源程序: 用三种排序:冒泡排序,直接插入排序,直接选择排序 #include <iostream>#define N 5using namespace std; template <typename T>//冒泡排序 /*void bubble_sort(T a[], int n){ int i, 阅读全文
posted @ 2020-02-06 09:02 bobo哥 阅读(124) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>using namespace std;template <class T> class max{private: T x, y;public: max(T a, T b) { x = a; y = b; } T compare() { return 阅读全文
posted @ 2020-02-05 23:31 bobo哥 阅读(106) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>using namespace std;template <class T> class Sample{ T n;public: Sample(T i) { n = i; } int operator ==(Sample &);}; template 阅读全文
posted @ 2020-02-05 23:05 bobo哥 阅读(126) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>using namespace std;template <class T> void f(T a[],int n){ T t; for (int i = 0; i < n / 2; i++) { t = a[i]; a[i] = a[n-i-1]; 阅读全文
posted @ 2020-02-05 22:30 bobo哥 阅读(115) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>using namespace std;template <class T> class A{private: T x, y, s;public: A(T a, T b) { x = a; y = b; s = x + y; } void show() 阅读全文
posted @ 2020-02-05 21:59 bobo哥 阅读(115) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>using namespace std;template <class T> class f{public: T x, y; void f1(T a, T b) { x = a; y = b; } T max() { return (x > y) ? 阅读全文
posted @ 2020-02-05 21:48 bobo哥 阅读(140) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>#include <string>using namespace std;template<class T>class TBase{ T data1;public: void print() { cout << "TBase::" << data1 < 阅读全文
posted @ 2020-02-05 21:29 bobo哥 阅读(296) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>#include <string>using namespace std;template<class T>class TBase{ T data1;public: void print() { cout << "TBase::" << data1 < 阅读全文
posted @ 2020-02-05 21:26 bobo哥 阅读(116) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>using namespace std;template <int i>class TestClass{public: int buffer[i]; int getData(int j);};template <int i>int TestClass< 阅读全文
posted @ 2020-02-05 21:20 bobo哥 阅读(155) 评论(0) 推荐(0) 编辑
摘要:源程序: #include<iostream>using namespace std;template<typename T>class Test{public: Test(T num) { k += num; } Test() { k += 1; } static void incrementK( 阅读全文
posted @ 2020-02-05 21:08 bobo哥 阅读(140) 评论(0) 推荐(0) 编辑
摘要:源程序: #include<iostream>#include<string>using namespace std;template<class T1, class T2>class Pair{public: T1 first; T2 second; Pair(T1 k, T2 v) :first 阅读全文
posted @ 2020-02-05 21:05 bobo哥 阅读(150) 评论(0) 推荐(0) 编辑
摘要:源程序: #include<iostream>using namespace std;template<class T>class TestClass{public: T buffer[10]; T getData(int j);};template <class T>T TestClass<T>: 阅读全文
posted @ 2020-02-05 21:02 bobo哥 阅读(93) 评论(0) 推荐(0) 编辑
摘要:源程序: #include<iostream>#include<string>using namespace std;template<class T1, class T2>class Pair{public: T1 first; T2 second; Pair(T1 k, T2 v) :first 阅读全文
posted @ 2020-02-05 20:59 bobo哥 阅读(124) 评论(0) 推荐(0) 编辑
摘要:源程序: #include<iostream>using namespace std;template<class T>T Max(T a, T b){ cout << "Template Max 1" << endl; return 0;}template<class T,class T2>T M 阅读全文
posted @ 2020-02-05 20:56 bobo哥 阅读(139) 评论(0) 推荐(0) 编辑
摘要:源程序: #include<iostream>using namespace std;class myDate{public: myDate(); myDate(int, int, int); friend ostream & operator<<(ostream & os, const myDat 阅读全文
posted @ 2020-02-05 20:48 bobo哥 阅读(92) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>#include <string>using namespace std;template <typename T>int myCompare(const T& left, const T& right){ if (left<right) { retu 阅读全文
posted @ 2020-02-05 20:45 bobo哥 阅读(135) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>using namespace std;template<class T> //类类型Tvoid Swap(T &x, T &y) //可以交换类对象{ T tmp = x; x = y; y = tmp;}class myDate{public: m 阅读全文
posted @ 2020-02-05 20:13 bobo哥 阅读(139) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>using namespace std;template <typename T>T abs(T x){ return x<0 ? -x : x;}int main(){ int n = -5; int m = 10; double d = -.5; 阅读全文
posted @ 2020-02-05 20:00 bobo哥 阅读(141) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>#include <fstream>using namespace std; class triangle{private: int a, b, c; double area;public: triangle(int aa, int bb, int c 阅读全文
posted @ 2020-02-05 19:49 bobo哥 阅读(148) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>#include <fstream>using namespace std; int main(){ char k; int i; ofstream outf("c:\\tmp\\tem.dat",ios::trunc); outf << "Hello 阅读全文
posted @ 2020-02-05 18:47 bobo哥 阅读(183) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>#include <fstream>using namespace std; int main(){ int i; ifstream f1("c:\\tmp\\xt1.txt",ios::in); fstream f2("c:\\tmp\\xt2.tx 阅读全文
posted @ 2020-02-05 17:34 bobo哥 阅读(145) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>#include <fstream>using namespace std; int main(){ int i; ofstream ftxt1; ftxt1.open("c:\\tmp\\xt1.txt",ios::out); for (i = 1; 阅读全文
posted @ 2020-02-05 17:26 bobo哥 阅读(198) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>#include <fstream>using namespace std; class CStudent{public: char id[11]; //学号 char name[21]; //姓名 int score; //成绩};int main( 阅读全文
posted @ 2020-02-05 14:52 bobo哥 阅读(202) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>#include <fstream>#include <iomanip>using namespace std; class CStudent{public: char id[11]; //学号 char name[21]; //姓名 int scor 阅读全文
posted @ 2020-02-05 14:33 bobo哥 阅读(140) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>#include <fstream>#include <iomanip>using namespace std;class CStudent{public: char id[11]; //学号 char name[21]; //姓名 int score 阅读全文
posted @ 2020-02-05 13:52 bobo哥 阅读(112) 评论(0) 推荐(0) 编辑
摘要:源程序: #include<iostream>#include<fstream>using namespace std;class CStudent{public: char id[11]; char name[21]; int score;};int main(){ char ch; cout < 阅读全文
posted @ 2020-02-05 13:48 bobo哥 阅读(129) 评论(0) 推荐(0) 编辑
摘要:源程序: #include<iostream>#include<fstream>using namespace std;class CStudent{public: char id[11]; char name[21]; int score;};int main(){ CStudent stu; o 阅读全文
posted @ 2020-02-05 13:41 bobo哥 阅读(102) 评论(0) 推荐(0) 编辑
摘要:源程序: #include<iostream>#include<fstream>#include<cstdlib>using namespace std;const int MAX_NUM = 1000;class CStudent{public: char id[11]; char name[21 阅读全文
posted @ 2020-02-05 13:34 bobo哥 阅读(144) 评论(0) 推荐(0) 编辑
摘要:源程序: #include<iostream>#include<fstream>#include<iomanip>using namespace std;int main(){ char ch, filename[20]; int count = 0; bool newline = true; co 阅读全文
posted @ 2020-02-05 13:27 bobo哥 阅读(134) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>#include <fstream>#include <iomanip>using namespace std;int main(){ char id[11], name[21]; int score; ifstream inFile; inFile. 阅读全文
posted @ 2020-02-05 13:13 bobo哥 阅读(113) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>#include <fstream>using namespace std;int main(){ char id[11], name[21]; int score; ofstream outFile; outFile.open("c:\\tmp\\s 阅读全文
posted @ 2020-02-05 13:10 bobo哥 阅读(92) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>#include <fstream>using namespace std;int main(){ ifstream inFile("c:\\tmp\\test.txt", ios::in); //声明对象inFile并调用构造函数 if (inFil 阅读全文
posted @ 2020-02-05 13:02 bobo哥 阅读(135) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>#include <fstream>using namespace std;int main(){ ifstream inFile; inFile.open("c:\\tmp\\test.txt", ios::in); //以读的方式打开文本文件 if 阅读全文
posted @ 2020-02-05 12:58 bobo哥 阅读(135) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <string>#include <iostream>#include <algorithm>using namespace std;int main(){ string str = ""; getline(cin, str, '\n'); reverse(str.beg 阅读全文
posted @ 2020-02-05 12:39 bobo哥 阅读(105) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>#include <string>#include <iomanip>using namespace std; class student{private: string name1; float score1;public: int i; stude 阅读全文
posted @ 2020-02-05 11:59 bobo哥 阅读(126) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>#include <iomanip>#include <string>using namespace std; int main(){ double x = 3; cout << setiosflags(ios::showpoint|ios::fixe 阅读全文
posted @ 2020-02-05 09:27 bobo哥 阅读(122) 评论(0) 推荐(0) 编辑
摘要:源程序: #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哥 阅读(151) 评论(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哥 阅读(116) 评论(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哥 阅读(141) 评论(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哥 阅读(212) 评论(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哥 阅读(148) 评论(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哥 阅读(205) 评论(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哥 阅读(150) 评论(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哥 阅读(120) 评论(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哥 阅读(142) 评论(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哥 阅读(169) 评论(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哥 阅读(141) 评论(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哥 阅读(159) 评论(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哥 阅读(135) 评论(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哥 阅读(195) 评论(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哥 阅读(116) 评论(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哥 阅读(152) 评论(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哥 阅读(138) 评论(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哥 阅读(113) 评论(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哥 阅读(146) 评论(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哥 阅读(141) 评论(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哥 阅读(139) 评论(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哥 阅读(136) 评论(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哥 阅读(95) 评论(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哥 阅读(120) 评论(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哥 阅读(104) 评论(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哥 阅读(87) 评论(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哥 阅读(107) 评论(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哥 阅读(118) 评论(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哥 阅读(183) 评论(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哥 阅读(172) 评论(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哥 阅读(197) 评论(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哥 阅读(114) 评论(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哥 阅读(112) 评论(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哥 阅读(93) 评论(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哥 阅读(177) 评论(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哥 阅读(166) 评论(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哥 阅读(114) 评论(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哥 阅读(124) 评论(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哥 阅读(133) 评论(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哥 阅读(133) 评论(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哥 阅读(117) 评论(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哥 阅读(116) 评论(0) 推荐(0) 编辑