![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
[ C++语言基础 ]
过去不再从来
反应有点慢
展开
-
C++基础知识(1)
编辑/编译 vim test.cpp g++ test.cpp -o test 1.域:using namespace std; 2.引用(与指针的区别) 引用不再单独分配内存,只是原来的一个别名. 引用必须初始化;(?) 3.分配空间: int *p = new int[10]; delete [] p;释放 malloc/free(是系统函数;c/c++都可用)原创 2013-10-30 22:46:43 · 496 阅读 · 0 评论 -
C++写链表
#include using namespace std; typedef int datatype; struct node { datatype data; node *next; }; class List { private: node *head; public: List();//构造 List(int n); ~List();//析构原创 2013-12-17 19:02:48 · 593 阅读 · 0 评论 -
虚函数
http://zhidao.baidu.com/link?url=hr35U2k2IiYe6idGcCXTkj034K0UVpgFGxIwVsE4_JqbCix5LLVW9pgmLDZbtmdWoM6aFS0mOfO2vdrGV7D2y_ 虚函数联系到多态,多态联系到继承。所以本文中都是在继承层次上做文章。没了继承,什么都没得谈。 下面是对C++的虚函数这玩意儿的理解。 一,转载 2014-01-14 14:19:57 · 488 阅读 · 0 评论 -
内联函数
#include #include using namespace std; class AA{ private: int a; int b; public: void seta(int x){//内联函数 a=x; } void setb(int y){ b=y; } int geta(){ return a; } int getb(){原创 2013-12-16 23:20:30 · 499 阅读 · 0 评论 -
string
1 #include 2 #include 3 using namespace std; 4 5 int main(){ 6 int a(10); 7 cout 8 string s1="hello";//类 对象;实例 9 string s2="world";//==string s原创 2013-12-16 23:09:07 · 461 阅读 · 0 评论 -
引用
1 #include 2 3 using namespace std; 4 void swap(int &x,int &y){ 5 6 int z=x; 7 x=y; 8 y=z; 9 } 10 int main(){ 11 int a=10; 12 // in原创 2013-12-16 23:03:16 · 473 阅读 · 0 评论 -
C++基础知识(4)
#include using namespace std; class date{ int m; int t; int days; public: static int tmp[12]; date(); void show(); int to_days(int m,int t); ~date(); date operator+(int d);原创 2013-10-30 23:02:13 · 493 阅读 · 0 评论 -
C++基础知识(3)
#include using namespace std; class person{ private: int age; public: //下面三个函数都是重载 person();//构造函数。 person(int a);//构造函数重载 person(person &b);//拷贝构造函数 void show(); ~person();原创 2013-10-30 22:58:35 · 558 阅读 · 0 评论 -
C++基础知识(2)
#include using namespace std; class person{ private: int age; public: person(int a);//构造函数 void show(); ~person();//析构函数 }; person::person(int a) { cout age = a; }原创 2013-10-30 22:54:17 · 482 阅读 · 0 评论 -
c++的概念
面向对象编程的特点是继承和动态绑定。C++通过类的派生支持继承,通过虚拟函数支持动态绑定。虚拟函数提供了一种封装类体系实现细节的方法。原创 2014-02-13 10:57:53 · 445 阅读 · 0 评论