Back to Basics: Functions in C++ - Mike Shah - CppCon 2023 - CppCon

What is the name of the speaker and the event he is leading?

The name of the speaker is Mike Shaw and he is leading the Back to Basics session on functions at CPPcon.

What is the duration of the session and what is the intended level of knowledge for the attendees?

The session is 60 minutes long and is intended for an introductory level. It is organized by Mike Shaw and Claus Ingberg as part of the Back to Basics and software development tracks.

What is the origin story of the speaker in relation to learning about functions?

The speaker, Mike Shaw, first learned about functions through a basic programming language called Dark Basic Pro, which he used to build games. He found a set of functions in the standard library that he could use to perform specific tasks, and this sparked his interest in the power of functions in programming.

What are some interesting things happening at assembly lines 39 and 40 in the given video transcript?

At assembly lines 39 and 40, the arguments supplied to the function are being stored in registers, which can be thought of as variables in the assembly context.

What does the 'ad' function do in the given video transcript?

The 'ad' function adds the two numbers passed as arguments and returns the result. It also sets up the return address and actual work of the function.

What is the purpose of the 'pragma once' directive in the given video transcript?

The 'pragma once' directive ensures that the header file, which contains declarations, is copied and pasted only once, preventing multiple duplication errors.

What are member functions in C++, and how do they differ from methods in other languages?

In C++, member functions are functions defined inside a class scope, which operate on the data members of the class. They are similar to methods in other object-oriented languages, but the terminology is more commonly used in C++. While some other languages might use the term 'methods' to refer to both class and object-level functions, in C++, member functions are typically referred to as 'member functions' when they are part of a class definition, and 'methods' when they are invoked on an object.

What is the purpose of the virtual keyword and override in C++, and how do they relate to inheritance and function implementation?

The virtual keyword in C++ is used to indicate that a member function can be overridden in derived classes. When a base class function is marked virtual, a virtual table (vtable) is created for each class or struct, which keeps track of the appropriate function implementation to call based on the actual object type. The override keyword is used in derived classes to explicitly indicate that a function is intended to override a virtual function from the base class. This helps ensure that the correct function is called at runtime and provides a way to implement polymorphism in C++.

What is the role of constexpr in C++, and how does it help with compile-time computation?

constexpr is a keyword in C++ that suggests to the compiler that a function or variable can be evaluated at compile time. When a function is marked constexpr, the compiler can optimize the code by performing the computation during the compilation process, rather than at runtime. This can lead to performance improvements, as the computation is done once during the compilation and the result is embedded in the executable. Additionally, constexpr functions can help developers write more expressive and flexible code, as they can be used in contexts where only constant expressions are allowed, such as template arguments.

What is the term for using the same function name with different parameters in C++?

Function overloads

What is the concept of argument dependent lookup in C++?

It is a rule that helps determine which function to call based on the types or scope of the arguments.

What is a functor in C++?

A functor is an object that overloads the function call operator () and can be used like a function, often used to keep track of state.