Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    Operatore ternario nel cout

    Devo concatenare una stringa e una variabile nel risultato di un operatore ternario:
    codice:
    cout<<(a?(a<<" anni"):"nulla")<<endl;
    Mi restituisce errore perché considera "<<" come shift binario.
    Come posso fare?

  2. #2
    Utente di HTML.it L'avatar di shodan
    Registrato dal
    Jun 2001
    Messaggi
    2,381
    codice:
    ( (a) ? cout << a << "anni"  : cout << "nulla" ) << endl;
    This code and information is provided "as is" without warranty of any kind, either expressed
    or implied, including but not limited to the implied warranties of merchantability and/or
    fitness for a particular purpose.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.