About 998,000 results
Open links in new tab
  1. Proper way to initialize C++ structs - Stack Overflow

    Jan 21, 2017 · Our code involves a POD (Plain Old Datastructure) struct (it is a basic c++ struct that has other structs and POD variables in it that needs to get initialized in the beginning.) …

  2. What are the differences between struct and class in C++?

    The difference between struct and class keywords in C++ is that, when there is no specific specifier on particular composite data type then by default struct or union is the public …

  3. When should you use a class vs a struct in C++? [duplicate]

    The differences between a class and a struct in C++ are: struct members and base classes/structs are public by default. class members and base classes/structs are private by …

  4. Can a struct have a constructor in C++? - Stack Overflow

    629 In C++ the only difference between a class and a struct is that members and base classes are private by default in classes, whereas they are public by default in structs. So structs can …

  5. struct - C++ Structure Initialization - Stack Overflow

    Treating a struct like a C++ class - in C++ structures are actually special types of classes, where all members are public (unlike a standard C++ class where all members are private if not …

  6. How to initialize a struct to 0 in C++ - Stack Overflow

    Apr 16, 2020 · Here is a related C answer that doesn't work (as a zero initializer for a struct) in C++: Initializing a struct to 0. One of the solutions presented is this: myStruct _m1 = {0}; This …

  7. Iterating over a struct in C++ - Stack Overflow

    Note that adding the output stream function to the struct requires the struct to be declared a certain way, so if anybody is getting errors trying to implement this, the location of the struct …

  8. Difference between 'struct' and 'typedef struct' in C++?

    In C, the struct tags, union tags and enumeration tags share one namespace, rather than (struct and union) using two as claimed above; the namespace referenced for typedef names is …

  9. c++ - Initializing default values in a struct - Stack Overflow

    May 28, 2013 · If I needed to initialize only a few select values of a C++ struct, would this be correct:

  10. C++, how to declare a struct in a header file - Stack Overflow

    3 You've only got a forward declaration for student in the header file; you need to place the struct declaration in the header file, not the .cpp. The method definitions will be in the .cpp (assuming …