- 博客(127)
- 资源 (1)
- 收藏
- 关注
原创 代码构建 premake4 例子
Building the Source Code//构建代码Premake can be built in either "release" (the default) or "debug" modes. If you are using Makefiles (as opposed to an IDE), you can choose which configuration to build with the config argument://构建模式 1.release版本 2.debug版本
2020-05-29 14:33:27
747
原创 gdb调试或者打印地址时候为啥只有48位?
例如:0x7fffd2f48c10根本原因:当前的x86_64处理器硬件限制所致。因为目前面世的x86_64处理器的地址线只有48条,硬件要求传入的地址的48到63位必须与47位相同。因为这个相同的原因也就是说剩下的16位要那么是 0x0000 要么是0xffff 也就是说情况1(剩下的16位都是0):BIN二进制64位是 0000 0000 0000 0000 0000 0000 000...
2019-11-06 15:08:02
922
原创 字符串化操作符#得作用
#include <stdio.h>#define f(a, b) a##b#define g(a) #a#define h(a) g(a)int main(){ printf("%s\n", h(f(1,2))); printf("%s\n", g(f(1,2))); return 0;}//考察字符串化操作符#得作用得执行过...
2019-11-05 17:28:15
829
原创 shell脚本批量创建删除账号
#!/bin/bashUSERS_INFO=/root/addusers.txtUSERADD=/usr/sbin/useraddUSERDEL=/usr/sbin/userdelPASSWD=/usr/bin/passwdCUT=/bin/cutwhile read LINESdo USERNAME=`echo $LINES | $CUT -f1 -d' '` ...
2019-09-24 17:58:28
560
原创 位操作实现m的n次方
#include <stdio.h>#include <stdlib.h>int pow(int m, int n){ int sum = 1; while(n != 0) { if(n&1 == 1) { sum *= m; } m *= m;...
2019-09-16 14:44:02
501
原创 C++ new map erase delete 不delete时候重复使用问题 各种情况测试代码
#include <iostream>#include <map>using namespace std;#include <stdio.h>struct A{ int x; int y; A(int v1, int v2) : x(v1), y(v2) {}};class B{ public:/*...
2019-06-18 15:55:50
1338
原创 go语言 面向对象 面向过程举例解释
package mainimport "fmt"type intt int //面向对象func (a intt) less(b intt) bool { return a > b }//面向过程func intt_less(a intt, b intt) bool { return a > b }func main() { var...
2019-04-17 17:08:01
678
原创 c signal函数与system函数小应用
#include<sys/types.h>#include<iostream>#include<stdio.h>#include<stdlib.h>#include<errno.h>#include<unistd.h>#include<fcntl.h>#include<string.h
2019-01-22 14:40:33
481
1
原创 C++ 实际项目中设置全局变量三种方法
#include<iostream>using namespace std;#include<stdlib.h>#include<stdio.h>/** method one *****/template<typename T>class Singleton{ public: static T& Instance(...
2019-01-11 18:21:22
6118
原创 C++ template模版长期举例总结
example_1#include<iostream>using namespace std;#include<stdio.h>template<typename T>class ID{ public: ID() : a(0) {} T getA() { return a;} void setA(T a_) { ...
2019-01-10 11:39:19
285
原创 C++ vector resize 后 之前保存数据是否清除(不清除)的测试用例
#include <iostream>using namespace std;#include<vector>#include<stdio.h>int main(){ std::vector<int> a; a.push_back(10); a.push_back(10); if(a.size() &l...
2019-01-07 17:55:30
6001
原创 #if #if defined #if !defined #elif defined #else #elif !defined #ifndef #define
#if __WORDSIZE == 64typedef long int __quad_t;typedef unsigned long int __u_quad_t;#elif defined __GLIBC_HAVE_LONG_LONG__extension__ typedef long long int __quad_t;__extension__ typedef unsigned...
2019-01-02 14:18:45
6935
翻译 C 中 ptrdiff_t简单思考举例
#include<stdio.h>#include<stddef.h>struct stuff{ char name[16];};typedef struct stuff STF;STF array[] = { {"12"}, {"122"}, {"123"}, {"12s"}, {"12x"}, {"132
2018-12-26 15:33:35
392
原创 extern "C" 与 __cplusplus 安全使用
无意中看源码看到的代码风格 如果已经宏定义 __cplusplus 则加入extern "C" 文件目录为/usr/include/event2/http_struct.h#ifndef _EVENT2_HTTP_STRUCT_H_#define _EVENT2_HTTP_STRUCT_H_/** @file event2/http_struct.h Data structure...
2018-12-25 20:20:45
180
原创 C++ map 覆盖 前后插入比较 前数据被覆盖
#include<iostream>#include<map>#include <stdio.h>using namespace std;int main(){ std::map<int, int> a; std::map<int, int> b; a.insert(std::make_pair(1...
2018-12-20 11:43:14
2093
原创 函数指针的两个简单用法
/************************************************************************* > File Name: func.cpp > Author: yangjx > Mail: yangjx@126.com > Created Time: Sat 15 Dec 2018 12:28:19 PM C...
2018-12-15 13:17:50
184
原创 VBS excel 导出生成lua文件
Class TaskDesc public id public name public typeTask public klass public state public frd public reqLev public taskPre1 public taskPre2 public taskPre3 public taskPre4 public taskPre5 pub...
2018-04-02 11:43:22
415
原创 C++ 转换函数举例
#include<iostream>#include<vector>using namespace std;class A{ public: A(int a, int b) : a(a), b(b) {} inline int operator <<(int c) { return a + c;} inline oper...
2018-04-02 11:41:35
295
翻译 临时和永久关闭Selinux
临时关闭:[root@localhost ~]# getenforceEnforcing[root@localhost ~]# setenforce 0[root@localhost ~]# getenforcePermissive永久关闭:[root@localhost ~]# vim /etc/sysconfig/selinuxSELINUX
2018-01-08 22:29:35
147842
3
原创 centos7.2安装 Redmine 3.4.3-2 (64-bit) Bitnami Redmine Installer
1.下载地址:https://bitnami.com/redirect/to/170722/bitnami-redmine-3.4.3-2-linux-x64-installer.run2.安装修改bitnami-redmine-3.4.3-2-linux-x64-installer.run 权限为可执行执行bitnami-redmine-3.4.3-2-linux-x64-ins
2018-01-04 12:01:49
2350
1
翻译 C++ explicit关键字
首先, C++中的explicit关键字只能用于修饰只有一个参数的类构造函数, 它的作用是表明该构造函数是显示的, 而非隐式的, 跟它相对应的另一个关键字是implicit, 意思是隐藏的,类构造函数默认情况下即声明为implicit(隐式).#include #include #include using namespace std;class A{ publi
2017-12-06 17:44:46
172
原创 C++中的mutable关键字
#include using namespace std;class A{ public: A() { count = 0; } ~A() {} void Out() const { std::cout << "ttttt" << std
2017-12-06 17:11:01
153
翻译 析构函数声明为私有的作用
当我们规定类只能在堆上分配内存时,就可以将析构函数声明为私有的。class alloc{public: alloc():private: ~alloc();}; 如果在栈上分配空间,类在离开作用域时会调用析构函数释放空间,此时无法调用私有的析构函数。如果在堆上分配空间,只有在delete时才会调用析构函数。
2017-11-28 18:59:43
1040
转载 centos 7 网卡命名新的规则 和之前不一样
CentOS6之前基于传统的命名方式如:eth1,eth0....Centos7提供了不同的命名规则,默认是基于固件、拓扑、位置信息来分配。这样做的优点是命名是全自动的、可预知的,缺点是比eth0、wlan0更难读。比如enp5s0一、网卡命名的策略systemd对网络设备的命名方式规则1:如果Firmware或者BIOS提供的设备索引信息可用就用此命名
2017-11-27 23:25:24
1167
原创 函数指针的简单举例
#include using namespace std;void A(int a, int b){ std::cout << "AAA:" <<a << " " << b << std::endl;}void B(int a){ std::cout << "BBB:" <<a << std::endl;}typedef void (*FUNC_A)(int
2017-11-20 17:52:30
365
原创 C++ 指针 new delete 赋值各种情况总结
#includeusing namespace std;int main(){ int* a = new int(100); std::cout << *a << " " << a << std::endl; //情况1 普通变量b /* * 结果 * 100 0x440f010 * 100 0x7fff6ff320d4
2017-08-02 11:16:36
2258
原创 模版 基类 父类 指针 正确保存数据
#include#include#includeusing namespace std;struct A{ int a; A():a(0) {} A(int ta) : a(ta) {}};struct AA:public A{ int aa; AA():A(), aa(0) {} AA(int ta, int taa): A(ta), aa(taa) {}};
2017-07-26 17:33:40
354
原创 C++ cant appear in a constant-expression bug修复
例:class KK{public: template void GetA() { A s; }};int main(){ int a = 14; KK s; s.GetA();}会报 a cant appear in a constant-expressio
2017-07-06 20:39:03
5621
原创 MySQL 远程登录 和遇到问题解决
大体思路:MySQL本地 设置允许远程登录信息(包括IP地址等)本地重启远程连接问题:在Linux下安装MySQL,默认情况下只允许本地localhost或者127.0.0.1地址访问mysql,用IP地址访问mysql数据库时,会出现无法连接的错误。ERROR 1045 (28000): Access denied for user 'root'@'192.168
2017-06-17 10:07:49
386
原创 fork函数与I/O函数之间的交互关系
UINX环境高级编程 第三版#includeint globvar =6; char buf[] = "a write to stdout\n";int main(void){ int var; pid_t pid; var = 88; if(write(STDOUT_FILENO, buf, sizeof(buf)-1) != size
2017-06-01 22:45:25
294
原创 C++ 迭代器 it返回的内容以指针方式返回
#includeusing namespace std;#includeclass A{ public: int* GetA(int b) { for(std::vector::iterator it = _a.begin(); it != _a.end(); ++it) {
2017-03-13 11:21:39
5787
原创 C++ template简单应用
#includeusing namespace std;#includetemplateclass A{ private: T a;};templateclass A1 : public A{ private: V a1;};template, typename V = int>class B{ public
2017-03-09 14:45:54
355
原创 C++ 容器 new 删除问题
#include#includeusing namespace std;int main(){ std::vector a; int* b = new int(10); a.push_back(b); for(std::vector::iterator it = a.begin(); it != a.end();) { std::
2017-03-07 09:33:18
891
原创 C++ 基类 派生类 互相转换 调用关系
#includeusing namespace std;class A{ public: A(int a) : _a(a ) { std::cout << "this is A" << _a << std::endl; } void GetA() { std::cout << "get a" << std::endl; } public: int _a;
2017-03-04 01:04:49
469
翻译 C++11 auto_ptr shared_ptr unique_ptr
转自: http://blog.youkuaiyun.com/xiejingfa/article/details/50750037 http://jingyan.baidu.com/article/9f7e7ec0b785ae6f281554f6.html http://blog.youkuaiyun.com/xiamentingtao/article/d
2017-02-21 19:21:03
323
原创 C++ shared_ptr 编译 error ‘shared_ptr’ was not declared in this scope修复
#include#include#include#includeusing namespace std;class Simple{ public: Simple(int p = 0) { number = p; std::cout << "Simple::" << number << st
2017-02-21 10:36:16
11386
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人