Trouble with namespaces and pointers

I am trying to compile the files below. The `PosLin.cpp` contains the `SurTriAUTO` and `getSphere` functions below. Although they are similar, I am not getting the same results. Is it because the "namespace TPiecesNS" causes them to be different?

I have a `tpieces.h` file

1
2
3
4
5
6
7
8
9
 namespace TPiecesNS
    {
      class TPieces
      {
      public:
        TPieces();
        //other stuff
      }
    }



`geopar.h` file has

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 #include "tpieces.h"
    #include "Geo/Geo.h"

    class Geo;

    namespace TpiecesNS
    {
       class GeoPar;
       {
        public:
              GeoPar();
              TPieces* getSphere(Geo* geo);
              TPieces* getSphere(Geo* geo, int permu);
        private:
	      TPieces* SurTriAuto(TPieces* boundary, Geo* geo,int permu);

       }
    }


`geopar.cpp` file has

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
#include "tpieces/geo.h"
    #include "tpieces.h"
    #include "Geo/Geo.h"

    using namespace TPiecesNS;

TPieces* GeoPar::getSphere(Geo* geo) {
  return getSphere(geo, 0);
}

TPieces* GeoPar::getSphere(Geo* geo, int permu)
{
	TPieces* boundary = new Sphere();
	return SurTri(boundary,geo,permu);
}
    
TPieces* GeoPar::SurTriAUTO(TPieces* boundary, Geo* geo, int permu)
{
        //stuff
	ofstream file;
	file.open("output.txt");
	file<< values;
	file.close()
	return boundary;
}


and `PosLin.h` has

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include "TPieces/tpieces.h"
    #include "Geo/Geo.h"

    struct PosRotAndQ {

      TPiecesNS::TPieces* boundary;
    };

    class PS{
    public: 

      PosExCode computation(Geo* geo, POpinion* opinion, PositionRotation* matterboundary)

      PositionRotation* matterboundary;
   
    }


and `PosLin.cpp` has

1
2
3
4
5
6
7
8
9
PosExCode PS::computation(Geo* geo, POpinion* opinion, PositionRotation* matterboundary)

{
    TPiecesNS::GeoPar* perform = new TPiecesNS::GeoPar();
    TPiecesNS::TPieces* boundary = new TPiecesNS::Sphere();
    boundary->sphere = perform->SurTriAUTO(boundary, geo,0);
    boundary->sphereDark[0] = perform->SurTriAUTO(boundary, geo,0); //if I comment this line out and un-comment the line below, they do not produce the same output
    //boundary->sphereDark[0] = perform->getSphere(geo,0);
}
Last edited on
Topic archived. No new replies allowed.