All Questions

504
votes
19answers
252204 views

What should main() return in C and C++?

What is the correct (most efficient) way to define the main() function in C and C++ — int main() or void main() — and why? If int main() then return 1 or return 0? There are numerous duplicate...
60
votes
3answers
31548 views

C++ virtual function return type

Is it possible for an inherited class to implement a virtual function with a different return type (not using a template as return)?
138
votes
4answers
17623 views

Why doesn't C# support the return of references?

I have read that .NET supports return of references, but C# doesn't. Is there a special reason? Why I can't do something like: static ref int Max(ref int x, ref int y) { if (x > y) return...
59
votes
9answers
57172 views

Returning anonymous type in C#

I have a query that returns an anonymous type and the query is in a method. How do you write this: public "TheAnonymousType" TheMethod(SomeParameter) { using (MyDC TheDC = new MyDC()) { var ...
92
votes
7answers
43235 views

Apply pandas function to column to create multiple new columns?

How to do this in pandas: I have a function extract_text_features on a single text column, returning multiple output columns. Specifically, the function returns 6 values. The function works, however...
47
votes
1answers
83578 views

How to return result of a SELECT inside a function in PostgreSQL?

I have this function in PostgreSQL, but I don't know how to return the result of the query: CREATE OR REPLACE FUNCTION wordFrequency(maxTokens INTEGER) RETURNS SETOF RECORD AS $$ BEGIN SELECT t...
15
votes
3answers
10170 views

Why should the assignment operator return a reference to the object?

I'm doing some revision of my C++, and I'm dealing with operator overloading at the minute, specifically the "="(assignment) operator. I was looking online and came across multiple topics discussing i...
16
votes
3answers
5651 views

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) -> int { return i; }; Basically, I did this because I wanted to store different function o...
32
votes
6answers
44332 views

Return multiple values from a Java method: why no n-tuple objects?

Why isn't there a (standard, Java certified) solution, as part of the Java language itself, to return multiple values from a Java method, rather than developers having to use their own means, such as ...
100
votes
4answers
27569 views

What's the difference between returning void and returning a Task?

In looking at various C# Async CTP samples I see some async functions that return void, and others that return the non-generic Task. I can see why returning a Task<MyType> is useful to return d...

Previous Next