
C/C++
你的牌打的太好啦
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Linux系统编程6.线程操作
编写的程序大多数可以看成是单线程的.就是程序是按照一定的顺序来执行.如果我们使用线程的话,程序就会在我们创建线成的地方分叉,变成两个”程序”在执行.粗略的看来好象和子进程差不多的,其实不然.子进程是通过拷贝父进程的地址空间来执行的.而线程是通过共享程序代码来执行的,讲的通俗一点就是线程的相同的代码会被执行几次.使用线程的好处是可以节省资源,由于线程是通过共享代码的,所以没有进程调度那么复杂。1.原创 2017-04-05 23:28:41 · 294 阅读 · 0 评论 -
12.命名空间
#include "iostream"using namespace std;//将名称空间std中名称到处全局 namespace Jack{ double pail; void swap(int &a,int &b); int pa; struct well { int a; int b; };}void原创 2017-04-02 00:52:04 · 273 阅读 · 0 评论 -
13.自定义类STOCK
STOCK.H #ifndef __stock00_h #define __stock00_h #include "string" class Stock //class declaration { private : //私有数据,仅可以在类中函数定义时访问,外部无法访问 ,不加private 也默认为私有 enum {NONE=0,ONE,TWO,TREE};//原创 2017-04-02 00:56:06 · 1022 阅读 · 0 评论 -
14.后缀const
#include <iostream> #include "stock00.h" #include "stock00.cpp" using namespace std; int main(void) { Stock stock_zu[5]=//类数组初始化 { Stock("awnt",5,1), Stock("wa",5,1),原创 2017-04-02 00:56:38 · 469 阅读 · 0 评论 -
15.自定义类VECTOR与操作符重载
#ifndef __Vector_h #define __Vector_h #include "iostream" class Vector { private: int x; int y; public: Vector(int x_,int y_); ~Vector(); Vector operator+(const Vec原创 2017-04-02 00:58:38 · 1441 阅读 · 0 评论 -
16.复制构造函数
#include "iostream" #include"DEV.hpp" int main(void) { //当成员中有new初始化的指针,则必须使用deep copy即定义复制函数 DER dev1=(3); //dev1调用构造; DER dev2; //dev2调用构造; DER dev3=dev2; //dev3调用构造;原创 2017-04-02 01:00:09 · 285 阅读 · 0 评论 -
17.静态成员函数
#include "iostream" class dev2 { private: int a; static int b; public: static void show(void) {std::cout<<"i am called"<<std::endl; }; }; //不能通过对象调用静态成员函数原创 2017-04-02 01:01:15 · 306 阅读 · 0 评论 -
18.类继承
#include "baseclass.hpp"#include "publicclass.hpp"int main(){{ base_class base1; public_class pub1(1,2,base1); base_class base2=public_class::base_class(); //基类指针和引用可在不显式转换下指向派生类对象原创 2017-04-02 01:02:58 · 286 阅读 · 0 评论 -
C变参编程
#include "stdio.h"#include "stdarg.h"#include "string.h"int demo(char *msg, ... ) { va_list argp; /*定义保存函数参数的个数*/ int argno = 0; /*记录函数参数的个数*/ ch原创 2017-04-02 01:08:29 · 614 阅读 · 0 评论 -
仿printf实现
多参数函数可以很好的写一个通信协议,下面试着实现printf#include "stdio.h"#include "stdarg.h"//变参函数包含库#include "string.h"char* apart_num_l(long num,char *buf,char length){ int i_; char ag; long num_=num; char原创 2017-04-03 18:03:38 · 452 阅读 · 0 评论 -
11.new用法
#include "iostream" using namespace std; int buff[200];//缓冲区 int main(void) { int *pa=new (buff) int; int *pb=new int; int *pc=new (buff) int[20]; delete pa,pb,pc; }原创 2017-04-02 00:51:20 · 236 阅读 · 0 评论 -
10.CV限定符
#include "iostream" using namespace std; int main(void) { const int a=5;//指定此值不可修改 volatile int c=6;//指定此值不可优化,假设编译器发现两次使用了这个变量,这时编译器可能将这个值放在一个寄存器中,volatile告诉编译器不优化 //也意味着 volatite 限定的变量原创 2017-04-02 00:50:22 · 438 阅读 · 0 评论 -
1.C++入门
#include "iostream"void print_add(int a,int b);int int_add(int a,int b);int main(){ using namespace std; cout<<"hello\r\n"; print_add(1,2);}void print_add(int a,int b){ using std原创 2017-04-02 00:36:12 · 220 阅读 · 0 评论 -
2.string类初始化
#include "iostream"using namespace std;int main(void){ string string1="string1"; string string2="string2"; string string3=string1+string2; cout<<"string1"<<string1<<endl; cout<<"st原创 2017-04-02 00:37:26 · 338 阅读 · 0 评论 -
3.cout char*
#include <iostream> using namespace std; int main(void){ char *str1 = "cout char *"; char str2[]="cout char []"; string str3="cout string"; string str5="cout string *"; string *st原创 2017-04-02 00:38:58 · 314 阅读 · 0 评论 -
4.输入缓冲
#include "iostream" using namespace std; int main(void) { char buff='\0'; string str1; for(;buff!='@';) { str1+=buff; cin.get(buff); } cout<<"you input is: \n"<<原创 2017-04-02 00:40:32 · 216 阅读 · 0 评论 -
5.new和delete
#include <iostream> int main(void){ using namespace std; int night = 1001; int * pt = new int; *pt = 1001; cout<<"night value = "<<night<<" ; location "<<&night<<endl; cout<<"i原创 2017-04-02 00:42:01 · 247 阅读 · 0 评论 -
6.引用
使用引用 #include "iostream" using namespace std; int main (void){ int a =7,b=8; int & c=a;//引用变量c相当于a的别名,引用赋值时必须初始化 int & d=b; cout<<"value a is: "<<a<<endl; cout<<"value b is: "<<b<<原创 2017-04-02 00:44:46 · 223 阅读 · 0 评论 -
7.函数的默认值
#include "iostream" //此项特性此编译器好像不支持 using namespace std; int add(int a,int b=1,int c=1,int d=1); int main (void) { cout<<"add a,b,c,d result is: "<<add(1,2); } int add(int a,int b=1,int c=1,原创 2017-04-02 00:45:38 · 215 阅读 · 0 评论 -
8.函数重载及其优先级
#include<iostream> using namespace std; //函数根据特征标进行重载:参数数目,参数类型,排列顺序 void add(int a,int b,int c) { a=a;b=b;c=c; cout<<"重载了add1"<<endl; } void add(int a,double b) { b=b; a=a;原创 2017-04-02 00:47:02 · 606 阅读 · 0 评论 -
9.函数模板
函数模板与模板显式具体化 #include "iostream" using namespace std; template <class anytype> //template <typename anytype> 与上面一样 anytype add(anytype a,anytype b)//模板也可以重载 { return a+b; } struct job {原创 2017-04-02 00:49:32 · 206 阅读 · 0 评论 -
链表
#include "stdio.h"#include "stdlib.h"struct __chain{ struct __chain* next_ptr; struct __chain* pro_ptr; int chain_number; struct { unsigned char data_a; unsigne原创 2017-04-03 18:04:34 · 168 阅读 · 0 评论