RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
c/c++强制去掉转移字符的办法以及仿函数

#include
#include

创新互联主营晋源网站建设的网络公司,主营网站建设方案,app软件开发公司,晋源h5小程序设计搭建,晋源网站营销推广欢迎晋源等地区企业咨询

using namespace std;
using namespace std::placeholders;


//去掉转移字符的方法
void main()
{
 //比如我门要打开qq
 //第一种
 string str = "C:\Program Files\QQ\Bin\QQ.exe";
 system(str.c_str());
 //有转移字符的存在是不是很蛋疼呢
 //接下来我们强制去掉转义字符
 //R"()"  可以强制去掉括号的转移字符  是不是很爽
 string str2 =R"( "C:\Program Files\QQ\Bin\QQ.exe")";
 system(str2.c_str());

 cin.get();
}

struct MyStruct
{
 void add(int a)
 {
  cout << a << endl;
 }
 void add2(int a, int b)
 {
  cout << a + b << endl;
 }
 void add3(int a, int b,int c)
 {
  cout << a + b+c << endl;
 }


};
//这个是 仿函数
void main23()
{
 MyStruct  struct1;
 auto func = bind(&MyStruct::add, &struct1,_1); //函数指针 直接用别人的成员函数
 //参数  加实例化  加 参数个数  即可绑定
 func(100); //fun是函数指针

 auto func2 = bind(&MyStruct::add2, &struct1, _1,_2);//表示占位
 func2(100, 20);

 auto func3 = bind(&MyStruct::add3, &struct1, _1, _2, _3);
 func3(10, 20, 50);
 //void(MyStruct*p)(int a) = &MyStruct::add;
 cin.get();
}


标题名称:c/c++强制去掉转移字符的办法以及仿函数
网站URL:http://sczitong.cn/article/jechei.html