Skip to content

Instantly share code, notes, and snippets.

@erincatto
Last active July 26, 2022 23:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erincatto/94d82f0140a3d48849483134f3efce21 to your computer and use it in GitHub Desktop.
Save erincatto/94d82f0140a3d48849483134f3efce21 to your computer and use it in GitHub Desktop.
const correctness
struct Foo
{
   int* data;
};

void DoStuff(const Foo& f)
{
   f.data[3] = 10;
}

int main()
{
  int buffer[5];
  Foo f;
  f.data = buffer;
  DoStuff(f);
  return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment