PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.cplus > Return from a function
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Return from a function

Réponse
 
LinkBack Outils de la discussion
Vieux 25/02/2008, 16h01   #1
Michael Bell
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Return from a function

I am a newbie, and looking through some code which I have been given
as an example of "how to do things right", I see functions like this:-

void FunctionName(void)

but in the function itself, after the "workings" I find :-

return StructName;
}


This seems very strange. It is declared as having no return type, but
yet it is written to return quite a big thing, and plainly the program
won't work unless it does return it. What's the explanation?

Michael Bell

--
  Réponse avec citation
Vieux 25/02/2008, 16h09   #2
Victor Bazarov
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Return from a function

Michael Bell wrote:
> I am a newbie, and looking through some code which I have been given
> as an example of "how to do things right", I see functions like this:-
>
> void FunctionName(void)
>
> but in the function itself, after the "workings" I find :-
>
> return StructName;
> }
>
>
> This seems very strange. It is declared as having no return type, but
> yet it is written to return quite a big thing, and plainly the program
> won't work unless it does return it. What's the explanation?


Somebody must have screwed up. Does it compile at all? AFAICT, it
shouldn't. But then again, you didn't post the complete code...

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask


  Réponse avec citation
Vieux 25/02/2008, 17h56   #3
Default User
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Return from a function

Michael Bell wrote:

> I am a newbie, and looking through some code which I have been given
> as an example of "how to do things right", I see functions like this:-
>
> void FunctionName(void)
>
> but in the function itself, after the "workings" I find :-
>
> return StructName;
> }
>
>
> This seems very strange. It is declared as having no return type, but
> yet it is written to return quite a big thing, and plainly the
> program won't work unless it does return it. What's the explanation?


Cut and paste the entire piece of code in question, not your
interpretation. Then we can see what we really have.




Brian
  Réponse avec citation
Vieux 25/02/2008, 21h39   #4
Juha Nieminen
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Return from a function

Default User wrote:
> Cut and paste the entire piece of code in question


Wouldn't that destroy the original? Sounds like a bad idea.
  Réponse avec citation
Vieux 25/02/2008, 22h12   #5
Default User
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Return from a function

Juha Nieminen wrote:

> Default User wrote:
> > Cut and paste the entire piece of code in question

>
> Wouldn't that destroy the original? Sounds like a bad idea.


Har.

I'm old enough to remember the days when the phrase meant exactly that,
you cut out the text with scissors or and Exact-o and pasted it into
your document.




Brian
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 03h05.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,10361 seconds with 13 queries