Icon Créer jeu Créer jeu

Programming Practice

Compléter

(2)
Practice for C++

Téléchargez la version pour jouer sur papier

Âge recommandé: 17 ans
11 fois fait

Créé par

United States

Top 10 résultats

  1. 1
    00:58
    temps
    100
    but
  2. 2
    01:42
    temps
    100
    but
  3. 3
    07:10
    temps
    13
    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

Programming PracticeVersion en ligne

Practice for C++

par Liz Smith
1

y 0 p2 Print p1 initX Move void Move p2 newY int newY namespace Point Print newX y int endl x cout initY

/ *
Purpose : declare a Point class type with inline member function to model a 2D point
* /

#include iostream / / for streaming i / o
using std ; / / reserve library for standard use

/ / declare the Point class to model a 2D point
class Point
{
public :
( ) { = ; y = 0 ; } / / the default constructor
Point ( int initX , int initY ) { x = ; = ; } / / the explicit contructor
void Print ( ) const { cout << " ( " << x << " , " << y << " ) " ; } / / to print a point
( , ) { x = newX ; = ; } / / to move a point
private :
int x ; / / the x coordinate
int y ; / / the y coordinate
} ;

int main ( )
{
Point p1 , / / declare a point at ( 0 , 0 )
p2 ( 1 , 2 ) ; / / declare a point at ( 1 , 2 )

/ / display p1 and p2

cout << " p1 = " ;
p1 . Print ( ) ;
cout << endl ;

/ / move p1 to ( 3 , 6 )
. ( 3 , 6 ) ;

/ / assign p1 to p2

p2 = p1 ;

<< " p2 = " ;
. ( ) ;
cout << ;

cout << " p2 = " ;
. ( ) ;
cout << endl ;

/ / successfully done
return 0 ;
}

educaplay suscripción