随笔分类 - C++
摘要:左值 右值 (纯右值,将亡值) 可以在等号左边 只能在等号右边 能够取到地址 不能取地址 具名 不具名 1. 变量名 2.返回左值引用的函数 3.解引用 (*this) 4. ++i是左值 5. 声明出来的左值引用 6.右值引用 1.返回非引用类型的函数调用 (int func(void)) 2.i
阅读全文
摘要:App调用接口,依赖头文件和库。 库文件更新,App代码不需要重新编译,直接就可以运行。 //main.cpp //main.cpp #include "IStudent.h" int main(){ getIStudent()->TellStory(); } //IStudent.h//#prag
阅读全文
摘要:#include <iostream> #include <tuple> using namespace std; template<class... Args> class student{ public: template<typename HEAD> void displayParam(con
阅读全文
摘要:#include <iostream> using namespace std; #define INITIALIZER(f) \ static void f(void) __attribute__((constructor)); \ static void f(void) #define DEIN
阅读全文
摘要:#include <iostream> using namespace std; class interface{ public: virtual int getAge()=0; virtual int getAge1()=0; }; class person:virtual public inte
阅读全文
摘要:#include <iostream> #include <iostream> #include <string> class test{ public: test(const std::string _domain,const std::string _interface,const std::s
阅读全文
摘要:随机产生数独初始值。 #include <iostream> #include <vector> #include <stack> #include <queue> #include <algorithm> #include <algorithm> using namespace std; void
阅读全文
摘要:文件锁 #include<iostream> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <errno.h> #include <string.h> #inc
阅读全文
摘要:#include<iostream> #include<algorithm> using namespace std; int main() { string s="Qasdaaddj"; sort(s.begin(),s.end()); cout<<s<<endl; return 0; } 1维数
阅读全文
摘要:int main() { string line,b; getline(cin,line); stringstream ss(line); while(ss>>b) { cout<<b<<endl; } } string读取某一行,然后按空格分隔吹每一个string char str[] = "no
阅读全文
摘要:g++ main.cpp 进行编译。 为了解决限定长度的赋值, 如果出现半个中文,则采取截断措施,解决中文乱码问题。 #include <iostream> #include <string.h> #include <stdio.h> using namespace std; #define MAX
阅读全文
摘要: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=...
阅读全文
摘要: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; } ...
阅读全文
摘要: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; }
阅读全文
摘要:判断占用字节数。
阅读全文
摘要:#include #include #include #include #include using namespace std; void saveConfigFile( string filePath, string keyStr,string replaceStr){ fstream file(filePath.c_str()); string line; ...
阅读全文
摘要:#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...
阅读全文
摘要:ubuntu@ubuntu-vm:~/workspace/template$ g++ main.cpp --std=c++11ubuntu@ubuntu-vm:~/workspace/template$ ./a.out 4
阅读全文
摘要:http://www.blogjava.net/fjzag/articles/317773.htmlubuntu@ubuntu-vm:/work/sv-g5-application/projects/sysmonitor/src$ cat SVPSysMonitor.cpp /*##########################################################...
阅读全文