Icon Créer jeu Créer jeu

Programming

Compléter

Practice Programming

Téléchargez la version pour jouer sur papier

Âge recommandé: 17 ans
5 fois fait

Créé par

United States

Top 10 résultats

  1. 1
    03:16
    temps
    99
    but
Voulez-vous apparaître dans le Top 10 de ce jeu? pour vous identifier.
Créez votre propre jeu gratuite à partir de notre créateur de jeu
Affrontez vos amis pour voir qui obtient le meilleur score dans ce jeu

Top Jeux

  1. temps
    but
  1. temps
    but
temps
but
temps
but
 
game-icon

Compléter

ProgrammingVersion en ligne

Practice Programming

par Liz Smith
1

SetSide int Square namespace endl GetArea side is GetSode bool cout initSide of void area s2 #include operator> s1 square side initSide The side return side const s1 side

Purpose : Overload operators for a class type as inline number functions


/ / for standard i / o
using std ; / / reserve library objects for standard use

/ / declare the Square class type to model a square
class Square
{
public :
Square ( ) { = 1 ; } / / the default constructor that initialize the side to 1
Square ( ) { = ; } / / the explicit constructor that initialize the side to a parameter
int ( ) { return side ; } / / get the side of the square
( int newSide ) { side = newSide ; } / / change the side of the
int GetArea ( ) const { return * ; } / / get the area of the square
( Square rhs ) const { > rhs . side ; } / / the greater operator
private :
int side ; / / the side of a square
} ;

int main ( )
{
, / / declared ( created ) by us the default constructor
s2 ( 3 ) ; / / declare ( created ) by using the explicit constructor
/ / display the area of s1 and s2
cout << " " << s1 . GetArea ( ) << endl ;
<< " The area of s2 is " << . ( ) < s2 )
cout << " s1 is bigger than s2 " < ( s2 ) )
else ;
cout << " s1 id not bigger than s2 " << ;

/ / successfully done
return 0 ;
}

educaplay suscripción