(C++) member variable

January 14, 2018 ยท View on GitHub

A member variable is a type of class member for an in-class variable. For example, a Person class might have a member variable to hold a Person his/her name.

#include <string>

struct Person
{
  std::string m_name;
  //Other member variables
};

int main()
{
  Person p;
  p.m_name = "John Doe";
}

LocalVersusGlobal is a simple benchmark that tests the speed of local versus member variables versus global variables.

Advice

References