1

I understand that you can use the static keyword for functions and variables to prevent them from being visible from other files. Can I use it for classes/structs? For example, inside a function, I use a struct that only that function uses, but I don't want to be able to use it from outside that file and I don't return that struct.

W. Albuquerque
  • 315
  • 2
  • 12

1 Answers1

0

Can I use the static keyword for classes and structs in C++?

No. However, you can define classes in an anonymous namespace which will prevent it from being named in other translation units.

eerorika
  • 232,697
  • 12
  • 197
  • 326