![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C++
C++,Modern C++
「已注销」
这个作者很懒,什么都没留下…
展开
-
C++正则表达式 2
C++正则表达式若要判断一个输入的QQ号是否有效,你会如何处呢?首先你得分析一下其对应规则,依次列出:长度大于5,小于等于11; 首位不能为0; 是否为纯数字?规则既列,接着就该尝试实现了,那么用什么来表示字符串呢?在C++中,最容易想到的就是string了,其中提供了许多成员函数可以处理字符串,所以有了如下实现:std::string qq;std::cin >> qq;// 1. 判断位数是否合法if (qq.length() >= 5 &&a.转载 2022-04-03 15:49:34 · 725 阅读 · 0 评论 -
C++正则表达式
C++正则表达式正则表达式在文本的查找和替换方面十分强大,最近恰巧用到,记录如下。使用的语言是C++,需要包含regex头文件,下面的代码是对linux系统路径的判别,我们假定路径都是下面这样的:./abcd ../abcd /abcd/efg#include <stdio.h>#include <string>#include <regex>#include <exception>#include <iostream&g转载 2022-04-03 15:38:26 · 1360 阅读 · 0 评论 -
C++ 输入输出流重载实例
#include <iostream>using namespace std;class rectangle { public: int length, width; rectangle(int l, int w) { length = l; width = w; } friend istream &operator>>(istream &.原创 2022-02-09 10:14:44 · 403 阅读 · 0 评论 -
C++ std::tuple std::tie
C++ std::tuple std::tie原创 2022-02-08 21:50:54 · 530 阅读 · 0 评论 -
C++ namespace
#include <iostream>using namespace std;namespace first_space { void func() { cout << "Inside first_space" << endl; }}namespace second_space { void func() { cout << "Inside second_space" << e.原创 2022-02-07 16:46:20 · 421 阅读 · 0 评论 -
C++ functors
#include <bits/stdc++.h>#include <iostream>using namespace std;class increment{ private: int num; public: increment(int n): num(n) {} int operator() (int arr_num) const { return num + arr_num;.原创 2022-01-29 10:12:01 · 772 阅读 · 0 评论 -
C++ lambda expression 01
#include <functional>#include <iostream>int main() { using namespace std; int i = 3; int j = 5; function<int (void)> f = [i, &j] { return i + j;}; i = 22; j = 44; cout << f() << endl; .原创 2022-01-28 10:30:10 · 634 阅读 · 0 评论 -
std::bind的使用
bind - C++ Referencestd::bind – Tutorial and Examples – thisPointer// bind example#include <iostream> // std::cout#include <functional> // std::bind// a function: (also works with function object: std::divides<double> m..转载 2021-12-14 16:15:42 · 91 阅读 · 0 评论