Top "Return-type" questions

is for questions dealing with the type of the variable or value returned by a function.

C# Overload return type - recommended approach

I have a situation where I just want the return type to be different for a method overload, but you …

c# .net overloading return-type
The body of constexpr function not a return-statement

In the following program, I have added an explicit return statement in func(), but the compiler gives me the following …

c++ function c++11 constexpr return-type
How can I return an anonymous struct in C?

Trying some code, I realized that the following code compiles: struct { int x, y; } foo(void) { } It seems as if …

c struct return-value c99 return-type
Java Unchecked Overriding Return Type

I have a project that has the following components: public abstract class BaseThing { public abstract <T extends BaseThing> …

java generics polymorphism abstract-class return-type
Swift function with Void return type versus no return type

I'm struggling with understanding return values in Swift. Can you explain the difference between these? func someFunc() -> Void {} …

swift function return-type
Why does Array.prototype.push return the new length instead of something more useful?

Ever since its introduction in ECMA-262, 3rd Edition, the Array.prototype.push method's return value is a Number: 15.4.4.7 Array.prototype.…

javascript specifications return-type
Can main() function return double?

Can the main() function in a C program return a double data type? If Yes, how and why? If No, …

c return-type
Differing return type for virtual functions

A virtual function's return type should be the same type that is in base class, or covariant. But why do …

c++ overriding virtual-functions return-type covariant
Return Type Covariance with Smart Pointers

In C++ we can do this: struct Base { virtual Base* Clone() const { ... } virtual ~Base(){} }; struct Derived : Base { virtual Derived* Clone() …

c++ smart-pointers virtual-functions return-type
Using `std::function<void(...)>` to call non-void function

A while ago I used std::function pretty much like this: std::function<void(int)> func = [](int i) …

c++ c++11 return-type std-function