(I'm using Visual C++ 2008) I've always heard that main() is required to return an integer, but here I didn't put in return 0; and and it compiled with 0 errors and 0 warnings! In the debug window it says the program has exited with code 0. If this function is named anything other than main(), the compiler complains saying 'blah' must ...
I want to return StudentId to use elsewhere outside of the scope of the $.getJSON()
j.getJSON(url, data, function(result)
{
var studentId = result.Something;
});
//use studentId here
I would imagine this has to do with scoping, but it doesn't seem to work the same way c# does
...
I've been doing a massive code review and one pattern I notice all over the place is this:
public bool MethodName()
{
bool returnValue = false;
if (expression)
{
// do something
returnValue = MethodCall();
}
else
{
// do something else
returnValue = Expression;
}
return re...
I have several similar methods, say eg. CalculatePoint(...) and CalculateListOfPoints(...). Occasionally, they may not succeed, and need to indicate this to the caller. For CalculateListOfPoints, which returns a generic List, I could return an empty list and require the caller to check this; however Point is a value type and so I can't r...
If I want to call Bar() instead of Foo(), does Bar() return me a copy (additional overhead) of what Foo() returns, or it returns the same object which Foo() places on the temporary stack?
vector<int> Foo(){
vector<int> result;
result.push_back(1);
return result;
}
vector<int> Bar(){
return Foo();
}
...
This question is a follow-up from How to indicate that a method was unsuccessful. The xxx() Tryxxx() pattern is something that can be very useful in many libraries. I am wondering what is the best way to offer both implementations without duplicating my code.
What is best:
public int DoSomething(string a)
{
// might throw an excep...
Hi all..
Was reading up a bit on my C++, and found this article about RTTI (Runtime Type Identification):
http://msdn.microsoft.com/en-us/library/70ky2y6k(VS.80).aspx . Well, that's another subject :) - However, I stumbled upon a weird saying in the type_info-class, namely about the ::name-method. It says: "The type_info::name member fu...
Is it possible to see the return value of a method after the line has been run and before the instruction pointer returns to the calling function?
I am debugging code I can't modify (read: don't want to re-compile a third party library), and sometimes it jumps to code I don't have source to or the return expression has side effects that...
I have a function called FindSpecificRowValue that takes in a datatable and returns the row number that contains a particular value. If that value isn't found, I want to indicate so to the calling function.
Is the best approach to:
Write a function that returns false if not found, true if found, and the found row number as a byref/out...
I am wondering what are the best practices for public methods and their return values. Is it ok to return types from referenced assemblies or should I make sure that all the parameters as well as return values are all from within the same assembly?
The reason I ask is that I am in the process of merging assemblies with ILMerge and I wo...
Is it possible to inspect the return value of a function in gdb assuming the return value is not assigned to a variable?
...
Hey!!
I am starting again with c++ and was thinking about the scope of variables.
If I have a variable inside a function and then I return that variable will the variable not be "dead" when it's returned because the scope it was in has ended?
I have tried this with a function returning a string and it did work.
Can anyone explain this?...
Yesterday, I found myself writing code like this:
SomeStruct getSomeStruct()
{
SomeStruct input;
cin >> input.x;
cin >> input.y;
}
Of course forgetting to actually return the struct I just created. Oddly enough, the values in the struct that was returned by this function got initialized to zero (when compiled using g++ t...
I think my eclipse's ctrl+clicking links might benefit greatly...
Edit: I'm using eclipse PDT.
Edit 2: I'm very happy with the solution of putting docblocks before functions (and variables) with an @return or @var statement, I've just updated the documentation of my app and now eclipse is showing me what functions are available to what...
I have a deceptively simple scenario, and I want a simple solution, but it's not obvious which is "most correct" or "most Java".
Let's say I have a small authenticate(Client client) method in some class. The authentication could fail for a number of reasons, and I want to return a simple boolean for control flow, but also return a Strin...
I'm implementing a COM interface that should return int values either S_OK or E_FAIL. I'm ok returning S_OK as I get that back from another call (Marshal.QueryInterface), but if I want to return a failure value what actual value do I use for E_FAIL?
(It's such a basic fundamental question that it's hard to find an answer to)
Assuming i...
I have a block of code that is repeated within a DB2 stored procedure.
I would like to separate this out into a new procedure that I can call with parameters and have it return a value.
How do I create a procedure to return a value and how do I call this procedure from inside my original procedure?
...
Hi!
I've got a mySql stored procedure that looks like this--
delimiter |
create procedure GetEmployeeById(in ID varchar(45))
begin
select id,
firstName,
lastName,
phone,
address1,
address2,
city,
state,
zip,
username,
password,
emptypeid
from myschema.tblemployees t
...
Dear all,
I have jquery that, i have called an ajax function file.php , that has some fields
like Milk , Will I assign into again JQuery function, If so how to do It?.I attached the sample file
<html>
<head>
<LINK REL=StyleSheet HREF="examples.css" TITLE="Contemporary" TYPE="text/css">
<script src="jquery-1.2.6.js" type="text/j...
When I am making methods with return values, I usually try and set things up so that there is never a case when the method is called in such a way that it would have to return some default value. When I started I would often write methods that did something, and would either return what they did or, if they failed to do anything, would r...