我已阅读了一些帖子,但无法弄清楚出了什么问题。我的代码是以下
#include <iostream>
using namespace std;
/* compiles with command line gcc xlibtest2.c -lX11 -lm -L/usr/X11R6/lib */
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xos.h>
#include <X11/Xatom.h>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
public class Point
{
int x;
int y;
public Point()
{
this.x=0;
this.y=0;
}
};
/*Code For XLib-Begin*/
Display *display_ptr;
Screen *screen_ptr;
int screen_num;
char *display_name = NULL;
unsigned int display_width, display_height;
Window win;
int border_width;
unsigned int win_width, win_height;
int win_x, win_y;
XWMHints *wm_hints;
XClassHint *class_hints;
XSizeHints *size_hints;
XTextProperty win_name, icon_name;
char *win_name_string = "Example Window";
char *icon_name_string = "Icon for Example Window";
XEvent report;
GC gc, gc_yellow, gc_red, gc_grey,gc_blue;
unsigned long valuemask = 0;
XGCValues gc_values, gc_yellow_values, gc_red_values, gc_grey_values,gc_blue_values;;
Colormap color_map;
XColor tmp_color1, tmp_color2;
/*Code For Xlib- End*/
int main(int argc, char **argv)
{
//////some code here
}
谢谢......它起作用了......我是个骗子的人.. 还有一件事
如果我写
,则会出错private int x; private int y;
如果在我使用的构造函数中 点() { this.x = 2; }
提前致谢
答案 0 :(得分:4)
将您的Java语法更改为:
class Point //access modifiers cannot be applied to classes while defining them
{
int x;
int y;
public : //Note a colon here
Point() :x(),y() //member initialization list
{
//`this` is not a reference in C++
}
}; //Notice the semicolon
答案 1 :(得分:3)
试试这个:
class Point {
int x;
int y;
public:
Point(): x(0), y(0) {
}
};
您使用的语法类似于Java。