相关分类: Java技术 C/C++ VB delphi
  • c++-多态和vptr指针

    c++-多态和vptr指针 多态的原理 #define _CRT_SECURE_NO_WARNINGS#include iostreamusing namespace std;class Parent{public: Parent(int a) { this-a = a; } virtual void func(int a) { cout Parent::func(int)... endl; } virtual void func(int a, int b, int c)...

    2019-12-22 16:02:13

  • c++-虚析构函数

    c++-虚析构函数 虚析构函数 #define _CRT_SECURE_NO_WARNINGS#include stdio.h#include stdlib.h#include string.h#include iostream#include fstreamusing namespace std;class A{public: A() { cout A()... endl; this-p = new char[64]; memset(this-p, 0, 64); str...

    2019-12-22 16:01:54

  • c++-多态的练习

    c++-多态的练习 多态的几个小练习 练习一 #include iostream#include stringusing namespace std;class Fu{public: Fu(string name) { this-name = name; } virtual void func() { cout 调用了Fu的函数endl; coutFu name func() endl; } string name;};class Zi :publi...

    2019-12-22 16:01:24

  • 使用动态数组,按照城市名字拼音排序

    使用动态数组,按照城市名字拼音排序 #includeiostream #includestdlib.h #includestring.h using namespace std; void input(char *city[],int n); void sort(char *city[],int n); int main() { int i= 0,m; cout"输入城市个数:"endl; cinm; char **city=new char *[...

    2019-12-22 16:00:58

  • c++-继承的学习

    c++-继承的学习 继承的基本概念 继承和派生 继承概念 派生类的访问控制(继承三种方式、类三种访问控制、三看原则)综合训练 继承中的构造和析构 类型兼容性原则 继承中的构造和析构 继承中同名成员函数、成员变量处理方法 继承中的static关键字 继承概念 派生类的访问...

    2019-12-22 16:00:54

  • 返回指针的函数

    返回指针的函数 //有一个使用coutGetName()的函数,每次执行结果都是只输出了传入字符串的首地址,即第一个字符,想了很久没有找到办法,后来将函数类型改为指针函数,结果就对了,仍然不是很明白为什么可以这样输出,隐隐觉得函数的返回值仍然是一个地址,也许是cout...

    2019-12-22 16:00:51

  • c++-类与类的关系

    c++-类与类的关系 类与类的关系 #define _CRT_SECURE_NO_WARNINGS#include iostreamusing namespace std;class A{public: void func() { cout funcA endl; } int a;};//类B拥有类A的成员变量, B has A ,//类B 依赖于 类Aclass B{public: void funcB() { } A a;};//耦...

    2019-12-22 16:00:50

  • c++-重载等号,数组,指针,字符串类

    c++-重载等号,数组,指针,字符串类 重载 重载=操作符 1先释放旧对象资源 2用一个对象=给另外一个对象 3函数返回值当左值 返回一个引用 4 数组类 Array operator=(Array a1); 5 字符串类:MyString operator=(const MyString obj); char operator const; 运算符重载难...

    2019-12-21 16:02:06

  • c++-重载运算符(+-,++,--,+=,-=,cin,cout)

    c++-重载运算符(+-,++,--,+=,-=,cin,cout) 操作符重载 自定义类型需要操作符重载 运算符重载入门技术推演 友元函数和成员函数实现2元运算符重载 友元函数和成员函数实现1元运算符重载(前置++,前置--,后置++,后置--) 友元函数实现运算符重载应用场景 #defi...

    2019-12-21 16:02:00

  • c++-友元函数和友元类

    c++-友元函数和友元类 友元函数 友元函数和友元类(破坏类的封装性) 面向对象编程思想 #define _CRT_SECURE_NO_WARNINGS#include iostream#include cmathusing namespace std;class Point;class PointManager {public: double PointDistance(Point p1, Point p2);};cl...

    2019-12-21 16:01:56

首页 上一页 48 49 50 51 52 53 54 55 56 57 58 下一页 末页 119311925
2