support bazel complie this project and format code.

This commit is contained in:
zhangxing
2023-03-30 00:15:11 +08:00
committed by light-city
parent 1f86192576
commit 3c8a3f259b
641 changed files with 10349 additions and 9523 deletions

34
cpp2.0/cpp11/nullptr.cpp Normal file
View File

@@ -0,0 +1,34 @@
//
// Created by light on 19-11-2.
//
#include <iostream>
using namespace std;
void f(int i) {
cout<<"void f(int i)" <<endl;
}
void f(void *p) {
cout<<"void f(void *p)" <<endl;
}
int main() {
f(0);
// #ifndef __cplusplus
// #define NULL ((void *)0)
// #else /* C++ */
// #define NULL 0
// c语言中将NULL定义为空指针而在c++中直接定义为0这是因为C++是强类型的void *是不能隐式转换成其他指针类型的。
if(NULL==0) cout<<"NULL==0"<<endl;
// f(NULL); // ambiguous,因为NULL==0所以存在二义性 指针也可以是个int的地址
// c++11 空指针nullptr
f(nullptr); //typedef decltype(nullptr) nullptr_t;
// nullptr_t为nullptr的类型
nullptr_t nl; // 使用nullptr_t定义的任何变量都具有nullptr一样的行为
f(nl);
return 0;
}