Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Exemple de création d’un tableau d’objet à deux dimensions


Download

 
#include <iostream>
using namespace std;
 
class Test {
  double a, b;
public:
  Test(double x, double y) {
    a = x;
    b = y;
  }
  void afficher_valeur() {
    cout << a << " " << b << endl;
  }
};
 
int main()
{
  Test ob[2][5] = {
    Test(1, 1), Test(2, 2),
    Test(3, 3), Test(4, 4),
    Test(5, 5), Test(6, 6),
    Test(7, 7), Test(8, 8),
    Test(9, 9), Test(10, 10)
  };
 
  int i, j;
 
  for(i = 0; i <2; i++)
    for(j=0; j<5; j++)
      ob[ i ][j].afficher_valeur();
 
  cout << 'n';
 
  return 0;
}
----------------------------------------------------------------------------

No comments yet.

Leave a Comment