随笔分类 -  C++

摘要:左值 右值 (纯右值,将亡值) 可以在等号左边 只能在等号右边 能够取到地址 不能取地址 具名 不具名 1. 变量名 2.返回左值引用的函数 3.解引用 (*this) 4. ++i是左值 5. 声明出来的左值引用 6.右值引用 1.返回非引用类型的函数调用 (int func(void)) 2.i 阅读全文
posted @ 2024-05-07 13:30 于光远 阅读(52) 评论(0) 推荐(0)
摘要:App调用接口,依赖头文件和库。 库文件更新,App代码不需要重新编译,直接就可以运行。 //main.cpp //main.cpp #include "IStudent.h" int main(){ getIStudent()->TellStory(); } //IStudent.h//#prag 阅读全文
posted @ 2022-07-14 20:21 于光远 阅读(127) 评论(0) 推荐(0)
摘要:#include <iostream> #include <tuple> using namespace std; template<class... Args> class student{ public: template<typename HEAD> void displayParam(con 阅读全文
posted @ 2022-07-13 18:23 于光远 阅读(55) 评论(0) 推荐(0)
摘要:#include <iostream> using namespace std; #define INITIALIZER(f) \ static void f(void) __attribute__((constructor)); \ static void f(void) #define DEIN 阅读全文
posted @ 2022-03-10 18:56 于光远 阅读(52) 评论(0) 推荐(0)
摘要:#include <iostream> using namespace std; class interface{ public: virtual int getAge()=0; virtual int getAge1()=0; }; class person:virtual public inte 阅读全文
posted @ 2022-03-10 15:58 于光远 阅读(85) 评论(0) 推荐(0)
摘要:#include <iostream> #include <iostream> #include <string> class test{ public: test(const std::string _domain,const std::string _interface,const std::s 阅读全文
posted @ 2022-03-10 14:26 于光远 阅读(659) 评论(0) 推荐(0)
摘要:随机产生数独初始值。 #include <iostream> #include <vector> #include <stack> #include <queue> #include <algorithm> #include <algorithm> using namespace std; void 阅读全文
posted @ 2020-08-02 03:29 于光远 阅读(277) 评论(0) 推荐(0)
摘要:文件锁 #include<iostream> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <errno.h> #include <string.h> #inc 阅读全文
posted @ 2020-07-24 21:31 于光远 阅读(411) 评论(0) 推荐(0)
摘要:#include<iostream> #include<algorithm> using namespace std; int main() { string s="Qasdaaddj"; sort(s.begin(),s.end()); cout<<s<<endl; return 0; } 1维数 阅读全文
posted @ 2020-07-22 10:54 于光远 阅读(211) 评论(0) 推荐(0)
摘要:int main() { string line,b; getline(cin,line); stringstream ss(line); while(ss>>b) { cout<<b<<endl; } } string读取某一行,然后按空格分隔吹每一个string char str[] = "no 阅读全文
posted @ 2020-07-21 20:54 于光远 阅读(3349) 评论(0) 推荐(0)
摘要:g++ main.cpp 进行编译。 为了解决限定长度的赋值, 如果出现半个中文,则采取截断措施,解决中文乱码问题。 #include <iostream> #include <string.h> #include <stdio.h> using namespace std; #define MAX 阅读全文
posted @ 2020-06-11 16:18 于光远 阅读(1221) 评论(0) 推荐(0)
摘要:static char char_flag;// 1111 ,figure ,lowercase ,uppercase,special char std::string generateString(){ std::string result = ""; srand((unsigned)time(NULL)); char_flag = 0; for(int i=... 阅读全文
posted @ 2018-10-25 14:25 于光远 阅读(166) 评论(0) 推荐(0)
摘要:void split(const string &s, char delim, vector &elems) { stringstream ss(s); string item; while (getline(ss, item, delim)) { elems.push_back(item); } // return elems; } ... 阅读全文
posted @ 2018-08-06 18:31 于光远 阅读(1625) 评论(0) 推荐(1)
摘要:输入: 输出: 阅读全文
posted @ 2018-07-29 19:19 于光远 阅读(616) 评论(0) 推荐(0)
摘要:string & trim(string &s){ if(s.empty()){ return s; } s.erase(0,s.find_first_not_of(" ")); s.erase(s.find_last_not_of(" ")+1); return s; } 阅读全文
posted @ 2018-07-29 15:02 于光远 阅读(171) 评论(0) 推荐(0)
摘要:判断占用字节数。 阅读全文
posted @ 2018-04-12 17:26 于光远 阅读(867) 评论(0) 推荐(0)
摘要:#include #include #include #include #include using namespace std; void saveConfigFile( string filePath, string keyStr,string replaceStr){ fstream file(filePath.c_str()); string line; ... 阅读全文
posted @ 2018-03-07 09:49 于光远 阅读(797) 评论(0) 推荐(0)
摘要:#define SVP_ENV(env_name, default_value) ({const char* env = getenv(env_name); env ? env : default_value;})#define SVP_VERSION SVP_ENV("SVP_VERSION", "")string str... 阅读全文
posted @ 2017-11-21 09:36 于光远 阅读(745) 评论(0) 推荐(0)
摘要:ubuntu@ubuntu-vm:~/workspace/template$ g++ main.cpp --std=c++11ubuntu@ubuntu-vm:~/workspace/template$ ./a.out 4 阅读全文
posted @ 2017-10-23 15:37 于光远 阅读(205) 评论(0) 推荐(0)
摘要:http://www.blogjava.net/fjzag/articles/317773.htmlubuntu@ubuntu-vm:/work/sv-g5-application/projects/sysmonitor/src$ cat SVPSysMonitor.cpp /*##########################################################... 阅读全文
posted @ 2017-07-11 10:19 于光远 阅读(271) 评论(0) 推荐(0)