Type Safety in Functions

blender

Saloni Goyal

Posted on November 22, 2020

Type Safety in Functions

C++ is a type safe language.

When you call a function, the parameters it takes have types. You provide the arguments and sometimes they need to be converted to the type of the parameters used. This conversion can be

  • possibly risky in which case the compiler will warn
  • passing a double (1.2) to a function which takes int parameter

The return value from the function might also be converted as part of assigning the value and this too could lead to compiler warnings if data is being thrown away.

Type safety rules apply everywhere in C++, from variables, to expressions as well as to functions.

Please leave out comments with anything you don't understand or would like for me to improve upon.

Thanks for reading!

💖 💪 🙅 🚩
blender
Saloni Goyal

Posted on November 22, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Type Safety in Functions
cpp Type Safety in Functions

November 22, 2020

Functions in C++
cpp Functions in C++

November 21, 2020

Keyboard Input
cpp Keyboard Input

November 21, 2020

Type Safety in C++
cpp Type Safety in C++

November 20, 2020