Autor Beitrag
CodexX
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 118

WinXP
Delphi XE
BeitragVerfasst: Do 02.12.04 00:49 
mal ne frage zu den lösungen vom 01.12.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
function max (a, b: Integer): Integer;  
begin  
  if a > b then result := a  
  else if b > a then result := b;  
end;

wieso soll diese funktion eine "warnung ausgeben"?
es handelt sich um eine funktion, die die größere zahl zurückgibt. mehr nicht. wobei bei
max(2, 2) nicht mal eine gewünschte rückgabe existiert, weil a=b. und dafür gibt es keine bedingung.

Moderiert von user profile iconKlabautermann: Gespittet aus Adventsgewinnspiel 2004 - Jetzt gehts los.... Bitte nur über fragen bereits ausgewerteter Gewinnspiele diskutieren, sonst drot ausschluss von den Gewinnspielen.
Moderiert von user profile iconChristian S.: Code- durch Delphi-Tags ersetzt.
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Do 02.12.04 00:53 
CodexX hat folgendes geschrieben:
und dafür gibt es keine bedingung.

Genau, und deshalb meldet Delphi : "Rückgabewert der Funktion 'max' könnte undefiniert sein".
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Do 02.12.04 00:54 
Wie wäre es wenn du es einfach mal ausprobierst..? ;)

Aber ich will mal nicht so sein.. mir meldet der Compiler:
Zitat:
[Warning] Unit1.pas(33): Return value of function 'max' might be undefined

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
Klabautermann Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Veteran
Beiträge: 6366
Erhaltene Danke: 60

Windows 7, Ubuntu
Delphi 7 Prof.
BeitragVerfasst: Do 02.12.04 00:55 
Hallo,
CodexX hat folgendes geschrieben:

wieso soll diese funktion eine "warnung ausgeben"?
es handelt sich um eine funktion, die die größere zahl zurückgibt. mehr nicht. wobei bei
max(2, 2) nicht mal eine gewünschte rückgabe existiert
, weil a=b. und dafür gibt es keine bedingung.

und genau davor warnt Delphi.
Delphi Compiler:
... Rückgabewert der Funktion 'max' könnte undefiniert sein


//Edit: Jaja, das Team kümmert sich.

Gruß
Klabautermann
maxk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1696
Erhaltene Danke: 1

Win XP, Debian Lenny
Delphi 6 Personal
BeitragVerfasst: Do 02.12.04 14:23 
Viel verwirrender fand ich die die Funktion, die eigentlich eine Procedure war (procedure Summe), weil ich nicht wusste, ob es eine Fangfrage ist, oder einfach nur (wie soll ich es formulieren) ein Missverständnis.

_________________
Ein Computer wird das tun, was Du programmierst - nicht das, was Du willst.
Lhid
ontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 831



BeitragVerfasst: Do 02.12.04 21:01 
Meinung und mich grundlegend geändert-> alte beiträge gelöscht


Zuletzt bearbeitet von Lhid am Sa 26.09.09 13:18, insgesamt 1-mal bearbeitet
Loki
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 34

Win XP Home

BeitragVerfasst: Do 02.12.04 21:23 
Das mit der Funktion und der Prozedur hab ich einfach in Delphi ausprobiert, aber ich wurde dann zuerst stutzig als ich gesehen habe das beide eine Meldung hatten, aber dann hab ich gesehen das man auch beide ankreuzen konnte :D

Nur bei der letzten Frage hab ich mehr geraten, weil ich irgendwie einen sehr blöden Suchbegriff eingegeben hatte und nichts brauchbares kam. Naja wenn man zu dumm ist zu suchen dann hat man nicht verdient das alles richtig ist ;)
Karlson
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 2088



BeitragVerfasst: Do 02.12.04 22:13 
Naja also das mit dem beiden ankreuzen hat mich die richtige Lösung gekostet :(
Da fänd ich es definitiv besser wenn die Antworten so gelautet hätten: Funktion1, Funktion2, beide.
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Do 02.12.04 22:29 
Ich fand das schon so in Ordnung, weil das ansonsten zu einfach gewesen wäre. Einfach nur A, B oder C ist simpel. Bei Checkboxes weiß man die Anzahl nicht.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Fr 03.12.04 17:23 
Mich hat erst etwas verwirrt, dass alle Dopplepunkte gefehlt haben. :roll:
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Fr 03.12.04 18:00 
Mir waren die Doppelpunkte egal, da nach den Warnungen und nicht nach den Syntax-Fehlern gefragt war. :mrgreen:

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.