tagged [struct]
How to set default values in Go structs
How to set default values in Go structs There are multiple answers/techniques to the below question: 1. How to set default values to golang structs? 2. How to initialize structs in golang I have a cou...
- Modified
- 13 Jul at 21:44
Method invocation on a struct?
Method invocation on a struct? When we invoke a method on a object, then the reference of the object is passed implicitly to the method. So my question is what happens when a method is invoked on a st...
How to print struct variables in console?
How to print struct variables in console? How can I print (to the console) the `Id`, `Title`, `Name`, etc. of this struct in Golang? ``` type Project struct { Id int64 `json:"project_id"` Title...
Compilation error. Using properties with struct
Compilation error. Using properties with struct Please explain the following error on struct constructor. If i change struct to class the erros are gone. ``` public struct DealImportRequest { public...
- Modified
- 2 Dec at 14:0
Difference between a Structure and a Union
Difference between a Structure and a Union Is there any good example to give the difference between a `struct` and a `union`? Basically I know that `struct` uses all the memory of its member and `unio...
What does newing an empty struct do in C#?
What does newing an empty struct do in C#? If you have declared a struct: What is the result of creating a variable of type `EmptyResult` in an instance? Would you expect an allocation on the stack, o...
Destroying a struct object in C#?
Destroying a struct object in C#? I am a bit confused about the fact that in C# only the reference types get garbage collected. That means GC picks only the reference types for memory de-allocation. S...
- Modified
- 27 Jan at 19:7
Returning two values, Tuple vs 'out' vs 'struct'
Returning two values, Tuple vs 'out' vs 'struct' Consider a function which returns two values. We can write: Which one is best practice and why?
- Modified
- 17 Jun at 06:12
How to make a 'struct' Nullable by definition?
How to make a 'struct' Nullable by definition? now if I want to have a `Nullable` instance I should write: But I want make the `struct` `Nullable` by nature and it can be used like this (without use o...
Initializing a struct to 0
Initializing a struct to 0 If I have a struct like this: What would be the easiest way to initialize this struct to 0? Would the following suffice? or Would I need to explicitly init each member to 0?
- Modified
- 3 Sep at 09:4
Why are mutable structs “evil”?
Why are mutable structs “evil”? Following the discussions here on SO I already read several times the remark that mutable structs are “evil” (like in the answer to this [question](https://stackoverflo...
- Modified
- 23 May at 12:26
Does it look like a C# bug for you?
Does it look like a C# bug for you? Create a console app to reproduce: It is compilable, but we will have the following at run time: > This approach solves the problem: ``` struct Test { public stat...
Copying one structure to another
Copying one structure to another I know that I can copy the structure member by member, instead of that can I do a `memcpy` on structures? Is it advisable to do so? In my structure, I have a string al...
How to check for an empty struct?
How to check for an empty struct? I define a struct ... Sometimes I assign an empty session to it (because nil is not possible) Then I want to check, if it is empty: Obviously this is not working. How...
typedef struct vs struct definitions
typedef struct vs struct definitions I'm a beginner in C programming, but I was wondering what's the difference between using `typedef` when defining a structure versus not using `typedef`. It seems t...
What does "request for member '*******' in something not a structure or union" mean?
What does "request for member '*******' in something not a structure or union" mean? Is there an easy explanation for what this error means? I've encountered it several times in the time that I've bee...
C - error: storage size of ‘a’ isn’t known
C - error: storage size of ‘a’ isn’t known This is my C program... This is the error that I am getting.... Press ENTER or type command to continue
Is it safe for structs to implement interfaces?
Is it safe for structs to implement interfaces? I seem to remember reading something about how it is bad for structs to implement interfaces in CLR via C#, but I can't seem to find anything about it. ...
How to use a struct inside another struct?
How to use a struct inside another struct? I want to use a nested structure, but I don't know how to enter data in it. For example: So in `main()` when I come to use it: Is that right? If not how do I...
"Overhead" of Class vs Structure in C#?
"Overhead" of Class vs Structure in C#? I'm doing course 3354 (Implementing System Types and Interfaces in the .NET Framework 2.0) and it is said that for simple classes, with members variables and fu...
default value for struct member in C
default value for struct member in C Is it possible to set default values for some struct member? I tried the following but, it'd cause syntax error: Errors: ``` $ gcc -o testIt test.c test.c:7: error...
self referential struct definition?
self referential struct definition? I haven't been writing C for very long, and so I'm not sure about how I should go about doing these sorts of recursive things... I would like each cell to contain a...
Program for documenting a C struct?
Program for documenting a C struct? If you have a binary file format (or packet format) which is described as a C structure, are there any programs which will parse the structure and turn it into neat...
- Modified
- 15 Dec at 22:8
Inherit from struct
Inherit from struct I am try to figure out what is the problem whit my code. I have this code: And i get this error: ``` Error at compile time: Type 'MyStructA' in interface list is not a
- Modified
- 14 Mar at 12:6