Why does C need “struct” keyword and not C++?

后端 未结 6 782
臣服心动
臣服心动 2020-11-27 03:38

I\'ve always been a little confused about what\'s going on here:

#include 

int main() {  
    timeval tv;
    tv.tv_sec = 1;

    for (;;) {
         


        
6条回答
  •  抹茶落季
    2020-11-27 04:33

    The way C does it came first, of course. Structs and classes in C++ are nearly identical, and it would have been very inconvenient to require class with every class variable so it was simplified for both.

提交回复
热议问题