Why are C++ classes allowed to have zero data members?

前端 未结 6 2143
遥遥无期
遥遥无期 2020-12-20 16:46

question about c++ why minimal number of data members in class definition is zero

i think it should be one , i.e pointer to virtual table defined by compiler

6条回答
  •  甜味超标
    2020-12-20 17:29

    Another use of a class with no data-members is for processing data from other sources. Everything gets passed into the class at runtime through pointers or references and the class operates on the data but stores none of it.

    I hadn't really thought about this until I saw it done in a UML class I took. It has it's uses, but it does usually create coupled classes.

提交回复
热议问题