Here is an example of passing mode as optional parameter
void myfunc(int blah, int mode = 0) { if (mode == 0) do_something(); else do_something_else(); }
you can call myfunc in both ways and both are valid
myfunc(10); // Mode will be set to default 0 myfunc(10, 1); // Mode will be set to 1
Related Posts:
- What is a segmentation fault?
- Return array in a function
- Regular cast vs. static_cast vs. dynamic_cast
- What is an unsigned char?
- C++ std::priority_queue uses the lambda expression
- When to use reinterpret_cast?
- Expression must be a modifiable lvalue
- How to read a file line by line or a whole text file at once?
- Split a string using C++11
- error: expected unqualified-id error: Meaning and fix? [duplicate]
- How to track down a “double free or corruption” error
- undefined reference to `WinMain@16′
- How can I clear console
- Graphics Library for C++
- ‘cout’ was not declared in this scope
- What is the difference between const int*, const int * const, and int const *?
- TranslateName() function doesn’t work on win10
- How to use the PI constant in C++
- How to concatenate two strings in C++?
- How to get current time and date in C++?
- where is the official c++ documentation
- wntdll.pdb not loaded – Can’t see the exception
- Networking with C++
- Error a function-definition is not allowed here before ‘{‘ token
- invalid new-expression of abstract class type error
- How can I create objects while adding them into a vector?
- warning: ISO C++ forbids variable length array
- cin >> “no operator matches these operands”
- C++ Structure Initialization
- expression preceding parentheses of apparent call must have (pointer-to-) function type
- Enum to String C++
- Random float number generation
- C++ terminate called without an active exception
- MinGW: “gcc is not recognized as an internal or external command”
- Convert Python program to C/C++ code?
- How to debug ‘Stack smashing detected’?
- basic_string::_M_construct null not valid after constructing subvector of strings
- Does C++ have a Garbage Collector?
- Sentinel while loop for C++
- How to ensure that a std::map is ordered?
- How to write C++ getters and setters
- std::out_of_range error?
- Checking cin input stream produces an integer
- How to convert vector to array
- “non-standard syntax; use ‘&’ to create a pointer to member” error in Visual Studio 2015
- libpng warning: iCCP: known incorrect sRGB profile
- C++: Expression must have a constant value when declaring array inside function
- What does ‘const static’ mean in C and C++?
- C++ wait for user input
- non-standard syntax; use ‘&’ to create a pointer to member
- How to shuffle a std::vector?
- Understanding glm::lookAt()
- How to get current timestamp in milliseconds since 1970 just the way Java gets
- What is the best open XML parser for C++?
- *** No rule to make target ‘class.cpp’, needed by `build/….x86/class.o` Stop. error in Ubuntu
- What’s the difference between opening a file with ios::binary or ios::out or both?
- Difference between ‘struct’ and ‘typedef struct’ in C++?
- Debug vs Release in CMake
- C++ Matrix Class
- access violation reading location c++
- C++ template constructor
- PlaySound in C++ Console application?
- Creation of Dynamic Array of Dynamic Objects in C++
- Compiling simple Hello World program on OS X via command line
- Cannot open output file, permission denied
- Strange error C2131: expression did not evaluate to a constant in VC 2015
- error: called object type ‘int’ is not a function or function pointer
- Cygwin Make bash command not found
- C++ Compiler Error C2280 “attempting to reference a deleted function” in Visual Studio 2013 and 2015
- Why use pointers?
- Why I cannot cout a string?
- How do I return a char array from a function?
- c++ reading csv file
- Why do you use typedef when declaring an enum in C++?
- What is wrong with using goto?
- Double pointer array in c++
- Converting String to Cstring in C++
- creating dynamic array of string c++
- How well is Unicode supported in C++11?
- The CXX compiler identification is unknown
- Is there a standard sign function (signum, sgn) in C/C++?
- C++ compiler error: “return type specification for constructor invalid”
- error: ISO C++ forbids in-class initialization of non-const static member
- Function call missing argument list to create pointer
- cannot specify explicit initializer for arrays
- What does ** mean in C++?
- Incomplete type is not allowed: stringstream
- “No rule to make target ‘install'”… But Makefile exists
- How to determine the version of the C++ standard used by the compiler?
- Make / gcc cryptic error 2: how to have more information?
- REGSVR32: the module “xxxxx.dll” failed to load … dependent assembly could not be found
- Error: expression cannot be used as a function?
- What is a .h.gch file?
- MinGW .exe requires a few gcc dll’s regardless of the code?
- Converting bool to text in C++
- clearing a vector of pointers [duplicate]
- Evaluate a string with a switch in C++ [duplicate]
- C++ JSON Serialization
- Template constructor in a class template – how to explicitly specify template argument for the 2nd parameter?
- C++ float array initialization