Questions tagged [void]

An incomplete type used as syntactic place-holder for the return type of a method/function when no value is returned.

void
Filter by
Sorted by
Tagged with
2 votes
1 answer
2k views

Empty closures in Swift 4.0 [duplicate]

I have been migrating my project code to Swift 4.0. I am facing an issue with closures. In the below code snippet: class ViewController: UIViewController { var completionClosure: ((Void)-&...
PGDev's user avatar
  • 24.1k
-4 votes
2 answers
4k views

C#:: What is the difference between int main(){...} void main(){...} int main(void){...} void main(void){...} [duplicate]

I am new to programming I am coding in C# and its kind of confusing. What is the difference between these: Thank you very much in advance!
Mario's user avatar
  • 1
4 votes
1 answer
2k views

Is void method in interface a code smell?

I mean design smell like temporal coupling. Void method has no type safe strict description in its signature about cases why and when it should be called. So it's only up to documentation. And using ...
SerG's user avatar
  • 1,263
0 votes
1 answer
1k views

Unit testing a void method in an internal static class

How do we go about testing a void method without instantiating the object in the test class? I understand in an internal static class we are unable to use "new" to create an object to test it. I've ...
nitric0's user avatar
-1 votes
1 answer
84 views

How to fix an operator to a void call in a button?

I'm a beginner C# dev and I am forgetting something. The (!ValidateCleared(actionsChecked))code is throwing and error the Operator ! cannot be applied to a void. Not sure how to fix this in this ...
Teresa Scudder's user avatar
-2 votes
1 answer
179 views

Void* when allocating [closed]

When is it appropriate to use void* space_to_use = malloc(size);
Karina Kozarova's user avatar
1 vote
1 answer
772 views

Unit testing WebApi controller that calls an async method with return type of void and Moq [duplicate]

I have a controller that calls a method that has a return type of void. I am also mocking up the object that method is a member of using Moq. Is there a special way to setup a mock with a method that ...
Matt Klepeis's user avatar
  • 1,724
22 votes
1 answer
15k views

Observable<void> usage pattern in Typescript

When an async service has no return value but I want to use Observables I'm inclined to use Observable<boolean>. But I don't have meaning for this boolean value because the service either fails ...
Halt's user avatar
  • 2,964
0 votes
1 answer
295 views

C++ Virtual Void

Okay, so I have a parent class called employee and 3 subclass called manager,researcher and engineer. I made a vector and want to list them. this is the how I process the making. vector <Employee*...
Ivan Apungan's user avatar
3 votes
1 answer
2k views

Generic typealias with Void gives error missing argument in Swift 4

When I tried to migrate to Swift 4 an error occurred with my generic typealias for closures if you give it Void as an input. This worked fine in Swift 3 but not so much now, anybody know why, and is ...
Cenny's user avatar
  • 1,966
0 votes
1 answer
237 views

How to place the information from a void pointer into a char array? [closed]

I am trying to put the information from a void pointer into a char array to keep track of what is at the beginning of a file instead of having to read the file every time I want to write to it to make ...
Nicholas Charles's user avatar
8 votes
4 answers
1k views

Towards understanding void pointers

In my answer I mention that dereferencing a void pointer is a bad idea. However, what happens when I do this? #include <stdlib.h> int main (void) { void* c = malloc(4); *c; &c[0]; } ...
gsamaras's user avatar
  • 72.8k
-2 votes
2 answers
143 views

function pointer array: void** cast

i am rather new to c and c++. I have the task (it is more for practise) to change a given c-module into c++. For this purpose, i have to understand the c files first. I have two specific questions, ...
DanK0904's user avatar
4 votes
6 answers
2k views

Why do we have to cast a void pointer to int or something else before printing the value in the memory whose address is in the pointer?

I wonder why is it necessary to cast a void pointer to an int * or char * before printing the contents of the address in memory, even though we tell the printf() function how to interpret the data in ...
user avatar
-4 votes
1 answer
971 views

Cannot assign value of type 'Void' (aka '()') to type '() -> Void' [duplicate]

There is a class instance of UIView that acts like a button. It has the property: public var endPressAction:(()->Void)? There is also a controller with the method: func didPressCell(_ indexPath:...
Mark's user avatar
  • 15
0 votes
2 answers
2k views

void(* resetDevice) (void) = 0; What kind of a function is this?

void(* resetDevice) (void) = 0; This was a function declaration I stumbled upon, moreover no definition found later. What kind of a function is this? What does it do? What does it return?
mr.ma's user avatar
  • 1
0 votes
1 answer
93 views

Having trouble understanding this function return

I am working with the following code I found on here to begin my project that involves a tree data structure. struct node{ int ID; struct node* next; struct node* child; }; typedef ...
user178831's user avatar
3 votes
1 answer
1k views

C++ conditional operator with void operand(s)

I’m trying to understand the following excerpt from the C++ standard (ISO/IEC 14882:2003, newer versions say essentially the same): 5.16 Conditional operator 2 If either the second or the ...
user1752563's user avatar
1 vote
1 answer
4k views

Emacs: Symbol's value as variable is void: Removes (init.el)

Sorry if this is a silly question; I am a complete novice when it comes to emacs. Recently, I began to do research on how to set up emacs and stumbled upon a great video series by Mike Zamansky. ...
Kyojin's user avatar
  • 13
0 votes
1 answer
130 views

How is it possible that println works inside void method?

public void debit (double amount){ if (balance<amount){ System.out.println("Amount withdrawn exceedes the current balance"); } else { balance-=amount; } } When I ...
Yurodivi's user avatar
-2 votes
1 answer
126 views

Java Intro to Class And Objects [closed]

An exercise in classes and objects that I was given to complete over the summer is driving me insane. I know it should be easy but for some reason, I can't get my head around it so I was hoping ...
KWMuller's user avatar
-3 votes
2 answers
1k views

Can I use nest a void inside another void in Java?

So, here's my code. public class Cay { public void Mesaj() { System.out.println("Başka bir sınıftan merhabalar!"); public void Araba() { System.out.println(&...
Ugur Aydın's user avatar
0 votes
2 answers
155 views

Cast multiple vectors to void *

I am currently working on a Roguelike where I have multiple different event queues(in the form of vectors), that handle multiple different event categories. Or rather, different game objects have ...
Druid's user avatar
  • 133
0 votes
2 answers
273 views

passing string from IEnumerator to void

I'm trying to pass a string from an IEnumerator to a void. but the string keeps coming out null :( here is my code: I'm new to this so please help Thanks all. my Void public void ResisterButton () { ...
user2960145's user avatar
0 votes
2 answers
733 views

In Swift 3, why is the void return value of functions, -> (), only sometimes inferred, but other times, must be declared?

Consider the following code: typealias bar = ()->() let foo:bar = { baz -> () in print("foobar") return () } let baz = foo() print("\(baz)") Which outputs: ...
CommaToast's user avatar
  • 11.7k
-5 votes
1 answer
92 views

Program failing to call void function [closed]

I am having trouble with writing this program. My issue seems to be with the processOrder and displayOrder functions, upon running this code the getOrder function runs just fine, but the program doesn'...
Cimel's user avatar
  • 11
4 votes
3 answers
3k views

Java Void to Scala Unit

I have a java library method requiring a class of Void as a parameter. for example, in com.mongodb.async.client.MongoCollection: void insertOne(TDocument document, SingleResultCallback<Void> ...
Luciano's user avatar
  • 2,398
-1 votes
1 answer
61 views

c++ if else statement won't go right pathway for text adventure game, always goes to the same Void Function

I have c++ issues. On a text adventure game I am making, and on a part where I have choices for different options on what to do in a house, every choice I make always goes to the void Sleep() function:...
Ejay's user avatar
  • 27
21 votes
1 answer
15k views

async Task vs async void

This might be a very stupid question, but I have the following lines of coding that convert RAW images to BitmapImages: public async void CreateImageThumbnails(string imagePath, int imgId) { await ...
CareTaker22's user avatar
  • 1,290
2 votes
3 answers
223 views

Confusion about malloc and calloc function in C [duplicate]

Declaration of malloc function: void *malloc(size_t size); Here, malloc returns void pointer. So, A void function returns nothing, then Why we assign malloc(function call) value to pointer? For ...
Jayesh's user avatar
  • 4,863
0 votes
2 answers
6k views

return statement in void function in C

In the following program, Why compiler does not gives any error or warning? cc -Wall -pedantic my_program.c code here: #include <stdio.h> void f() { return; // return statement in ...
Jayesh's user avatar
  • 4,863
30 votes
2 answers
47k views

What does Void return type mean in Kotlin

I tried to create function without returning value in Kotlin. And I wrote a function like in Java but with Kotlin syntax fun hello(name: String): Void { println("Hello $name"); } And I've got an ...
Mara's user avatar
  • 3,007
0 votes
1 answer
42 views

Control JFrame other void?

I want to control JFrame from "PART3" any help? StackOverFlow asking for more info ;) So my idea is in PART3 g.f I know this is wrong so any help import java.io.IOException; import javax.swing.JFrame;...
Mharles Canson's user avatar
0 votes
1 answer
47 views

Why pointer memory gets successfully able to save and retrive data from void memory allocation [duplicate]

#include <stdio.h> #include <stdlib.h> int main() { char *p = malloc(sizeof(void)); p[0] = 'a'; p[1] = 'b'; p[2] = 'c'; p[3] = 'd'; p[4] = 'e'; printf("%c\n",p[...
sagar's user avatar
  • 99
-1 votes
3 answers
4k views

Want to go back to a function on if/else statement

Please look at this code, and I will explain: void GameOver() { cout << "\nWelp, you died. Want to try again?" << endl; cin >> choice; if (choice == "Yes" || "yes") {...
Ejay's user avatar
  • 27
0 votes
2 answers
2k views

void or any type as a template parameter

I was wondering if there is a solution to specify a template so that either void or any other type can be passed. The following is a very simplified example, which should do nothing but return void if ...
Thomas Flinkow's user avatar
-4 votes
2 answers
2k views

Java void calculating the result from two different methods at main

hi i wanted to ask if i had two public void methods in another class like these, how can i calculate the result(res+result) the two of these at my main class ?.I had it for my homework. thanks for ...
user3290284's user avatar
1 vote
2 answers
207 views

C#: Add "Select" item to Dynamic Fill ComboBox method

I need to add "Select" at index 0 without know DataTable columns count or name because this method in DataAccessLayer and will use later` // ComboBox Fill Method public static void ComboBoxFill(...
Walid Moheyeldin's user avatar
0 votes
1 answer
21k views

Go - void function and direct assignment

I have a little problem in Go language. I have this struct: type Time struct{ hour,min,sec int } And this function that initializes it: func init_Time(t Time) (int,int,int){ t.hour, t.min, ...
mx88's user avatar
  • 27
1 vote
1 answer
8k views

Illegal type 'void' in Android Java Class

I have the error Illegal type 'void' in an Android Java Application. The error comes on the private void createFolder() and public void onRequestPermissionsResult code block. I dont know if there is ...
Antonio Gschossmann's user avatar
6 votes
3 answers
1k views

What is a real-world use-case for JavaScript's void operator?

Why would someone write: function () { if (err) { return void console.log(err) } } instead of: function () { if (err) { console.log(err) return } } Has ...
borislemke's user avatar
  • 8,846
9 votes
1 answer
10k views

NSubstitute - mock throwing an exception in method returning void

Using NSubstitute, how do you mock an exception being thrown in a method returning void? Let's say our method signature looks something like this: void Add(); Here's how NSubstitute docs say to ...
Kavya Shetty's user avatar
2 votes
4 answers
565 views

How to average vertically over a list containing a void list?

I have a list containing the following: list1 = [(4.974874129422414, 0.4384932775564907, 0.1879318517703546, 5.820735609514166, 0, 0), (0.15069597326856923, 0.2961961688603689, 0....
Guido De Haan's user avatar
0 votes
0 answers
52 views

encountering error while using reference in recursion

I wrote a code of recursion with two versions. The first one passed parameters by array of array, and had no error. The second one passed reference to vector of vector and the execution stopped in the ...
jombo's user avatar
  • 67
13 votes
1 answer
3k views

Purpose of class = void in C++? [duplicate]

What is the purpose of the class = void in the following code snippets? template< class, class = void > struct has_type_member : false_type { }; template< class T > struct has_type_member&...
msc's user avatar
  • 33.9k
15 votes
2 answers
977 views

Why (void) between two comma separated statements in a for loop [duplicate]

The following code comes from an implementation example of std::lexicographical_compare on cppreference.com: template<class InputIt1, class InputIt2> bool lexicographical_compare(InputIt1 ...
Vincent's user avatar
  • 59k
0 votes
0 answers
425 views

How to save data to List in void and then call it from another method

I am working on some project that calculate expenses of vehicle fleet. So basically i need to read all binary files and save it to a table in SQL server. Then i need to show some vehicle routes on ...
AnnuitCoeptis's user avatar
-2 votes
2 answers
1k views

converting void to string - void to object issue?

I have the following multi threaded code, that take a list of servers and async runs the heavyoperation, the heavy operation returns the results and im trying to the populate a multiline text box with ...
Dwayne Dibbley's user avatar
0 votes
0 answers
42 views

Looking for simple explanation of `CloudKit` code - inZoneWith and Void in

I have my successful code which run a query search from my cloud kit database but I haven't come across a solid explanation of the inZoneWith: nil portion and the (results, error) -> Void in piece, ...
Jon's user avatar
  • 85
1 vote
1 answer
852 views

Error: Invalid use of void

I'm compiling C++ source (main.cpp) with a C header (hps_linux.h). The code in hps_linux.h is: #ifndef HPS_LINUX_H_ #define HPS_LINUX_H_ #include <stdbool.h> #include <stdint.h> #...
Arturo Salas's user avatar

1
12 13
14
15 16
39