c++17(10)-nullptr和lambda

#include <iostream>
#include <bitset>
using namespace std;

int main(int argc, char **argv)
{
   char *x1=nullptr;
   char *x2="hello";
   auto funtest=[](char *myStr)->void{
        if (myStr!=nullptr){
           cout<<myStr<<endl;
        }
        else{
           cout<<"nullptr"<<endl;
        }
   };
   funtest(x1);
   funtest(x2);
}
nullptr
hello

Hit any key to continue...
发布了385 篇原创文章 · 获赞 13 · 访问量 5万+

猜你喜欢

转载自blog.csdn.net/AI_LX/article/details/104414833