C/C++
wangjinjing1984
Web 应用
展开
-
动态链表的创建
#include <stdio.h> //List结构样式 typedef struct node { int data; struct node *next; }Node; //创建head的空链 Node *createList() { Node *head = (Node *)malloc(sizeof(Node))...原创 2018-11-26 09:03:08 · 4624 阅读 · 0 评论 -
const 修饰数据成员、成员函数、类对象
#include <iostream> using namespace std; #if 0 const 修饰数据成员 成员函数 类对象 1. 修饰数据成员 初始化位置只能在参数列表里面 被const修饰的数据成员,不能被修改 2. 修饰成员函数 位置在 函数声明之后,实现体之前 意义:const 函数承诺不修改数据成员。 能访问co...原创 2018-11-26 09:04:48 · 425 阅读 · 0 评论 -
使用static创建堆与栈空间链表
#include <iostream> using namespace std; class List { public: List(int d) { data = d; #if 0 /*可以优化*/ if(NULL == head) { this->next = NULL; head = t...原创 2018-11-26 09:06:11 · 161 阅读 · 0 评论