File: demo_cpp.cpp

package info (click to toggle)
g2 0.61-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,828 kB
  • ctags: 1,037
  • sloc: ansic: 8,262; sh: 2,708; makefile: 222; perl: 186; fortran: 183; cpp: 34
file content (41 lines) | stat: -rw-r--r-- 681 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <stdio.h>
#include <iostream>
#include <g2_X11.h>
#include <g2.h>

/* A very simple example to demonstrate g2 in a C++ environment */


class Circle
{
public:
  Circle(int d, double x, double y, double r)
    : _d(d), _x(x), _y(y), _r(r)
  {
    g2_circle(d, x, y, r);
    g2_flush(d);
  }

  void Fill()
  {
    g2_filled_circle(_d, _x, _y, _r);
    g2_flush(_d);
  }
private:
  int _d;
  double _x, _y, _r;
};


int main(int argc, char *argv[])
{
    int d;
    d=g2_open_X11(100, 100);
    Circle c(d, 50, 50, 25);
    std::cout << "Press [Enter]" << std::endl;
    getchar();
    c.Fill();
    std::cout << "Press [Enter]" << std::endl;
    getchar();
    return 0;
}