
c/c++语言学习
c/c++相关程序用例
行星T
linux c/c++基础软件相关开发
展开
-
c++学习
类构造函数初始化列表c++#include <iostream> // std::coutusing namespace std;class CMyClassaa { public: CMyClassaa(int x, int y); int m_x; int m_y=5;};CMyClassaa::CMyClassaa(int x, int y) : m_y(y), m_x(m_y){}int main(){ CMyCl原创 2022-05-12 16:52:34 · 232 阅读 · 0 评论 -
内存管理maclloc,jemalloc
内存分配malloc一、c库函数Malloc()和free()Gun下默认会链接 libc库,路径为/lib64/libc.so.6。Malloc()类函数调用时相应的会调用libc中的maloc函数。定义如图所示,其中用了一些gun的c关键字,大概意思为malloc的是__libc_malloc的别名,__malloc也是__libc_malloc的别名。二、内存分配的具体实现在调用__libc_malloc函数时首先会判断全局钩子函数malloc_hook_ini是否被定义,在libc库原创 2022-05-11 13:08:34 · 2037 阅读 · 0 评论 -
可变参数宏__VA_ARGS__
宏定义中的可变参数 **…**可用宏__VA_ARGS__替代#include "stdio.h"#include "stdlib.h"#include "string.h"#include "time.h"int add(int a,int b,int c,int d,int f);#define INDIRECT_CALL_1(f, f1, ...) \ ({ \ (f == f1) ? f1(__VA_ARGS__) : f(__VA_ARGS__); \ }原创 2022-05-11 11:02:35 · 224 阅读 · 0 评论 -
c++学习
c++学习模板使用,求最大值#include <iostream>namespace guodong {template<class T>T max(T head) { return head;}template<class T, typename... Args>T max(T head, Args... args) { T t = max(args...); return (head > t)?head:t;}原创 2022-05-02 11:44:25 · 792 阅读 · 0 评论