refering back to the function question, and it's return:
A function is used to split up code.
so, say you had a program that connected to the internet, and it connected to a
specific address.
You would make a function, rather than rewriting this code how ever many times
it was needed in the code.
Thanks,
_|_|_|_|_| _| _|_|_|_|
_| _|_|_| _| _|_|_|
_| _| _| _|_|_| _|
_| _| _| _| _|
_| _| _| _|_|_|_| _|_|_|
Visit TDS for quality software and website production
http://tysdomain.com
msn: [EMAIL PROTECTED]
aim: st8amnd2005
skype: st8amnd127
----- Original Message -----
From: peternilsson42
To: [email protected]
Sent: Tuesday, September 23, 2008 9:07 PM
Subject: [c-prog] Re: returning a value
Robert Ryan <[EMAIL PROTECTED]> wrote:
>
> 1. if a function does not return a value, the last line
> executed is: return; is this right,
The following won't compile under C99 or C++...
int foo() { return; }
C++ requires that non void functions return a value.
C only requires non void functions to return a value if
the caller attempts to use the return value.
> because isn't the purpose of a function to return a
> value
What value does the following function return...?
void bar() { }
> 2. another question: misspelling 'sqrt' would result in
> a compile time error or a linker error
Depends on the misspelling.
> I would think a compile time
> error
C90 will assume an implicit function declaration for
a call to an undeclared named function. In such cases,
it's possible for a link error, or worse, no reported
error.
> 3. vector<int> v(6) means each int is initialized to 6
Ask yourself: if 6 is the value to initialise the ints
with, how many ints are initialised?
> 4. does a narrow_cast check for information that is lost
Depends on whoever's 'narrow_cast' you're using.
> 5. is the purpose of a grammar is to generate
> syntactically correct expressions
http://en.wikipedia.org/wiki/Formal_grammar
> 6. streams may be input, output or both
> 7. in the C++ statement: int& r = i; memory is
> allocated for i, but not for r
The declaration says nothing about the allocation
for i. The virtual C and C++ machines will allocate
storage for r. An optimiser may be able to remove
the need for actual memory allocation.
--
Peter
__________ NOD32 3466 (20080923) Information __________
This message was checked by NOD32 antivirus system.
http://www.eset.com
[Non-text portions of this message have been removed]