Auswahloperator

  • servus,

    ich hab da mal ne frage zum auswahloperator.
    wenn ich zum beispiel folgende zeile

    Code
    teams <= 0 ? teammaker( teams) : exit( 0);


    in meinen quelltext einbaue, mekert der borland compiler, dass keine werte vom type void erlaubt sein. soll das heißen, dass der auswahloperator keine void funktionen mag( dann müsste void exit() ) ?

    wenn ichs allerdings mit ner if anweisung mache, klappt alles.

    mfg paul

    • Anzeige

    Hallo!

    Wenn du gerade an deiner Website arbeitest oder dein aktuelles Hosting überdenkst: Wir betreiben mit NetzLiving eine Hosting-Plattform, die speziell auf Performance, Sicherheit und einfache Verwaltung ausgelegt ist.

    • ✔️ Schnelle Ladezeiten (optimiert für WordPress, WoltLab & Co.)
    • ✔️ Deutsche Server & DSGVO-konform
    • ✔️ Persönlicher Support (kein 0815-Ticket-System)

    Mehr erfahren

  • Hallo,
    Typ 1 muss ein integer,float oder pointer sein (Das vor dem ?)
    UND
    -If both operands have type void, the result has type void.
    -If either operand is a pointer to an object of any type, and the other operand is a pointer to void, the pointer to the object is converted to a pointer to void and the result is a pointer to void.
    -If either expression or conditional-expression is a pointer and the other operand is a constant expression with the value 0, the type of the result is the pointer type.

    Also ich vermute mal einfach er meckert an der Variabekl die davor steht rum als int a=(b<=0) ? 1:exit(0);
    wird nicht funktionieren.

    Wenn du die Varaibel a aber weglässt müsste es gehen:

    Code
    void f1( void );
    void f2( void );
    int x;
    int y;
        .
        .
        .
    ( x == y ) ? ( f1() ) : ( f2() );


    (zumindest MS lässt sowas zu)

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!