Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# null coalescing operator equivalent for c++

Tags:

Is there a C++ equivalent for C# null coalescing operator? I am doing too many null checks in my code. So was looking for a way to reduce the amount of null code.

like image 873
aajkaltak Avatar asked Nov 23 '09 19:11

aajkaltak


1 Answers

I just found this: The ?? operator aka the Null Coalescing Operator

You also have it in C/C++ as a GNU extension using the ?: operator :

string pageTitle = getTitle() ?: "Default Title"; 
like image 131
adamjhilton Avatar answered Sep 27 '22 19:09

adamjhilton