0

I want to create some private variables, but when i compile the program i get an error. If I move the variables above the class SimpleOpenNIViewer than it works.

This is the error Messages: /Workspace/virtual-reality/main.cpp:16:56: error: expected identifier before ‘new’ PointCloud::Ptr cloud_previous2 (new PointCloud);

This is how I have written the code. Can anyone tell me why this doesnt work?

class SimpleOpenNIViewer
     {
        private:
            PointCloud<PointXYZRGBA>::Ptr cloud_previous2 (new PointCloud<PointXYZRGBA>);
            PointCloud<PointXYZRGBA>::Ptr cloud_previous1 (new PointCloud<PointXYZRGBA>);
            PointCloud<PointXYZHSV>::Ptr cloud_HSVPrev2(new PointCloud<PointXYZHSV>);
            PointCloud<PointXYZHSV>::Ptr cloud_HSVPrev1(new PointCloud<PointXYZHSV>);
            PointCloud<PointXYZHSV>::Ptr cloud_HSVCurr(new PointCloud<PointXYZHSV>);
Neriman Arif
  • 13
  • 1
  • 7

2 Answers2

0

Ensure you have included all the relevant headers or forward declared classes your variables depend on.

Your class declaration also lacks a closing brace and semi colon.

greenback
  • 1,506
  • 2
  • 17
  • 29
0

Try this:

class SimpleOpenNIViewer
     {
        private:
            PointCloud<PointXYZRGBA>::Ptr cloud_previous2 = new PointCloud<PointXYZRGBA>;
            PointCloud<PointXYZRGBA>::Ptr cloud_previous1 = new PointCloud<PointXYZRGBA>;
            PointCloud<PointXYZHSV>::Ptr cloud_HSVPrev2 = new PointCloud<PointXYZHSV>;
            PointCloud<PointXYZHSV>::Ptr cloud_HSVPrev1 = new PointCloud<PointXYZHSV>;
            PointCloud<PointXYZHSV>::Ptr cloud_HSVCurr = new PointCloud<PointXYZHSV>;
MikeCAT
  • 73,922
  • 11
  • 45
  • 70
  • I did try, but I got a different error. /Workspace/virtual-reality/main.cpp:16:88: warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11 [enabled by default] PointCloud::Ptr cloud_previous2 = new PointCloud; – Neriman Arif Sep 27 '15 at 15:19
  • Alternatively declare the variables here and new them in the constructor. – greenback Sep 27 '15 at 15:22
  • @NerimanArif, So pass `-std=c++11` to the compiler. – chris Sep 27 '15 at 15:23