#include <iostream>

Source: Internet
Author: User

1 Std::ref () Implementing a reference wrapper

2 std::string string

1 Std::ref () Implementing a reference wrapper

The template function reference is not valid, so you need to reference the wrapper

Std::ref (), the function template directly references

1#include <iostream>2 using namespacestd;3 4Template <classT>5 voidCOM (T Arg)//The template function reference is not valid, so you need to reference the wrapper6 {7arg++;8Std::cout <<"void COM (T arg)"<< &arg << Std::endl;//not the same address .9 }Ten  One voidMain () A { -     intCountTen); -     int& Rcount (count);//References the  -Std::cout <<"the original value"<< Count << Std::endl;//Ten -  -COM (&count);//parameter is address +  -Std::cout <<"parameter is address"<< Count << Std::endl;//still ten +  ACOM (rcount);//parameter is a reference at  -Std::cout <<"parameter is a reference"<< Count << Std::endl;//still ten -  -Std::cout <<"Main"<< &count << Std::endl;//not the same address . -  -     //std::ref (variable name), function template Direct reference inCOM (std::ref(count)); -  toStd::cout <<"Reference Wrapper"<< Count << Std::endl;//become One +  -System"Pause"); the}

2 std::string string

R "(You can remove the escape character inside the parentheses)"

1#include <iostream>2 3 voidMain ()4 {5     //R "(You can remove the escape character inside the parentheses)"6STD::stringPath = R"("D:\Program Files\tencent\qqintl\bin\qq.exe")";7 8System (PATH.C_STR ());//Execution9 TenSystem"Pause"); One}

#include <iostream>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.