Top "Struct" questions

A keyword in various programming languages whose syntax is similar to or derived from C (C++, C#, Swift, Go, Rust, etc.

Copying structure in C with assignment instead of memcpy()

Up until recently, I have only seen copying of structure fields done with memcpy(). In classes and online instructions, copying …

c pointers struct memcpy
C++ Tuple vs Struct

Is there is any difference between using a std::tuple and a data-only struct? typedef std::tuple<int, double, …

c++ struct tuples
Python & Ctypes: Passing a struct to a function as a pointer to get back data

I've looked through other answers but can't seem to get this to work. I'm trying to call a function within …

python pointers struct ctypes
C++ define class member struct and return it in a member function

My goal is a class like: class UserInformation { public: userInfo getInfo(int userId); private: struct userInfo { int repu, quesCount, ansCount; }; …

c++ class function struct class-members
C++: Can a struct inherit from a class?

I am looking at the implementation of an API that I am using. I noticed that a struct is inheriting …

c++ class inheritance struct
Why can't structs be declared as const?

They are immutable value types on the stack. What keeps me from having them a const? References: http://msdn.microsoft.…

c# struct stack constants
C# Automatic deep copy of struct

I have a struct, MyStruct, that has a private member private bool[] boolArray; and a method ChangeBoolValue(int index, bool …

c# struct deep-copy default-copy-constructor
Are Structs always stack allocated or sometimes heap allocated?

I was of the impression that in C#, struct elements are allocated on the stack and thus disappear when returning …

c# struct allocation
Hiding members in a C struct

I've been reading about OOP in C but I never liked how you can't have private data members like you …

c struct private-members
Anonymous union within struct not in c99?

here is very simplified code of problem I have: enum node_type { t_int, t_double }; struct int_node { int …

c gcc struct c99 unions