Strange problem

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Strange problem

Morteza Romoozi

Hi

i run below code in visual c.net,but when i try to run exe file of it,face to error and cant run it.

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

typedef CGAL::Cartesian<double> K; typedef K::Point_2 Point;
typedef CGAL::Polygon_2<K> Polygon_2;
using std::cout; using std::endl;


int main()
{
Point *points;

points=new Point[pl];

for(j=0;j<pl;j++){

     points[j]=Point(2,4);}

}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Plz Help me


Reply | Threaded
Open this post in threaded view
|

Re: Strange problem

Mahmood Naderan
> when i try to run exe file of it,face to error and cant run it
 
What is the error message then?
 
-------------------
Mahmood Naderan
 

 

----- Original Message ----
From: Morteza Romoozi <[hidden email]>
To: [hidden email]
Sent: Friday, July 25, 2008 9:41:23 AM
Subject: [cgal-discuss] Strange problem

Hi

i run below code in visual c.net,but when i try to run exe file of it,face to error and cant run it.

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

typedef CGAL::Cartesian<double> K; typedef K::Point_2 Point;
typedef CGAL::Polygon_2<K> Polygon_2;
using std::cout; using std::endl;


int main()
{
Point *points;

points=new Point[pl];

for(j=0;j<pl;j++){

     points[j]=Point(2,4);}

}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Plz Help me



Reply | Threaded
Open this post in threaded view
|

Re: Strange problem

Morteza Romoozi
ther is no Error but i think it cant run

points=new Point[pl];

it stop when rich to this line

--- On Thu, 7/24/08, Mahmood Naderan <[hidden email]> wrote:
From: Mahmood Naderan <[hidden email]>
Subject: Re: [cgal-discuss] Strange problem
To: [hidden email]
Date: Thursday, July 24, 2008, 11:20 PM

> when i try to run exe file of it,face to error and cant run it
 
What is the error message then?
 
-------------------
Mahmood Naderan
 

 

----- Original Message ----
From: Morteza Romoozi <[hidden email]>
To: [hidden email]
Sent: Friday, July 25, 2008 9:41:23 AM
Subject: [cgal-discuss] Strange problem

Hi

i run below code in visual c.net,but when i try to run exe file of it,face to error and cant run it.

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

typedef CGAL::Cartesian<double> K; typedef K::Point_2 Point;
typedef CGAL::Polygon_2<K> Polygon_2;
using std::cout; using std::endl;


int main()
{
Point *points;

points=new Point[pl];

for(j=0;j<pl;j++){

     points[j]=Point(2,4);}

}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Plz Help me




Reply | Threaded
Open this post in threaded view
|

RE: Strange problem

Xiaofan Li-2
In reply to this post by Morteza Romoozi
As far as I remembered (might be inaccurate), new[] does not initialise all but the first element of the object array. It just allocates the necessary memory space. Try std::vector or std::list instead.
 
------------------------------------------------
Xiaofan Li
 
Biomolecular Modeling Laboratory
Cancer Research UK, London Research Institute
[hidden email] <mailto:[hidden email]>  
 
Department of Biochemistry and Molecular Biology
University College London
[hidden email] <mailto:[hidden email]>  
------------------------------------------------
 

________________________________

From: Morteza Romoozi [mailto:[hidden email]]
Sent: Fri 7/25/2008 07:11
To: [hidden email]
Subject: [cgal-discuss] Strange problem


Hi

i run below code in visual c.net,but when i try to run exe file of it,face to error and cant run it.

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

typedef CGAL::Cartesian <http://www.cgal.org/Manual/3.3.1/doc_html/cgal_manual/Kernel_23_ref/Class_Cartesian.html#Cross_link_anchor_1> <double <http://www.cgal.org/Manual/3.3.1/doc_html/cgal_manual/NumberTypeSupport_ref/Class_double.html#Cross_link_anchor_582> > K; typedef K::Point_2 <http://www.cgal.org/Manual/3.3.1/doc_html/cgal_manual/Kernel_23_ref/Class_Point_2.html#Cross_link_anchor_24>  Point;
typedef CGAL::Polygon_2 <http://www.cgal.org/Manual/3.3.1/doc_html/cgal_manual/Polygon_ref/Class_Polygon_2.html#Cross_link_anchor_668> <K> Polygon_2 <http://www.cgal.org/Manual/3.3.1/doc_html/cgal_manual/Polygon_ref/Class_Polygon_2.html#Cross_link_anchor_668> ;
using std::cout; using std::endl;


int <http://www.cgal.org/Manual/3.3.1/doc_html/cgal_manual/NumberTypeSupport_ref/Class_int.html#Cross_link_anchor_577>  main()
{
Point *points;

points=new Point[pl];

for(j=0;j<pl;j++){

     points[j]=Point(2,4);}

}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Plz Help me


--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://lists-sop.inria.fr/wws/info/cgal-discuss

winmail.dat (7K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

RE: Strange problem

Ben Galehouse
Quoting Xiaofan Li <[hidden email]>:

> As far as I remembered (might be inaccurate), new[] does not  
> initialise all but the first element of the object array. It just  
> allocates the necessary memory space. Try std::vector or std::list  
> instead.

new[] calls the default constructor (and only the default constructor)  
which should be fine in this case.

The only other quirk of new[] that I can think of is that you are  
supposed to use delete []. However, if you simply leave it allocated  
till the end, in something like this, it is normally only valgrind  
that complains. (Though of course this is a big deal in real code)

Addressing the original poster, there is nothing obviously wrong with  
the code besides those annoying links and some things that were  
apparently left out. Adding the delete [] and making changes  
sufficient to compile, I ended up with the file below, and it seems  
fine with gcc 4.3 under linux. It is highly likely that you have an  
overall configuration problem. Do the CGAL examples work? It might be  
that the more MS focused people here might be able to tell you more if  
you gave exact compiler version information and the like.

-----------------------

#include <CGAL/basic.h>
#include <CGAL/Point_2.h>
#include <CGAL/Cartesian.h>
#include <CGAL/Polygon_2.h>
typedef CGAL::Cartesian <double > K;
typedef K::Point_2 Point;
typedef CGAL::Polygon_2 <K> Polygon_2 ;
using std::cout;
using std::endl;

int  main()
{
Point *points;

points=new Point[ 5 ];

for(int j=0;j<5;j++){

      points[j]=Point(2,4);}

  delete [] points;
}
--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://lists-sop.inria.fr/wws/info/cgal-discuss