Hmm sorry for not getting what you want to say, but I want to be 100% I understood correct.

laserlight I do not have a constructor

Whiteflags, it is not clear to me if I need to use what you say or not

Maybe I should post all the code, so that you get the whole image

Code:

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/convex_hull_2.h>
#include <stack>
#include <CGAL/Polygon_2.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef K::Point_2 Point_2;
typedef CGAL::Polygon_2<K> Polygon;
Point_2 P0;
bool duplicatePoint(std::vector< Point_2 > &P, int pointPos, Point_2 &point);
bool cmp(const Point_2 &a, const Point_2 &b);
double findRad(const Point_2 &P, const Point_2 &P0);
int main()
{
CGAL::set_ascii_mode(std::cin);
CGAL::set_ascii_mode(std::cout);
std::istream_iterator< Point_2 > in_start( std::cin );
std::istream_iterator< Point_2 > in_end;
std::ostream_iterator< Point_2 > out( std::cout, "\n" );
std::vector< Point_2 > P (in_start, in_end);
std::vector< Point_2 > Q;
P0 = P[1];
int posP0 = 1;
// Srart from zero, in case 1st and 2nd points
// have same y coordinates
for(int i = 0 ; i < P.size() ; i++)
{
if( duplicatePoint(P, i, P[i]) )
P.erase (P.begin()+i);
if( P[i].y() < P0.y() )
{
P0 = P[i];
posP0 = i;
}
if( P[i].y() == P0.y() )
if( P[i].x() < P0.x() )
{
P0 = P[i];
posP0 = i;
}
}
std::cout<<" MIN = " <<P0<<std::endl;
P.erase(P.begin() + posP0);
std::cout<<"input<----------------"<<std::endl;
std::copy(P.begin(), P.end(), out);
std::cout<<"SORT<----------------"<<std::endl;
std::sort(P.begin(), P.end(), cmp);
std::copy(P.begin(), P.end(), out);
/* compute convex hull in Q from input P */
Q = P;
//TEST CGAL::convex_hull_2(Q.begin(), Q.end(), out ) ;
std::stack<Point_2> S;
S.push(P0);
S.push(P.at(1));
S.push(P.at(2));
Point_2 TOP;
Point_2 NEXTtoTOP;
for( int i = 3 ; i < P.size() ; i++ )
{
std::cout<<"Loop "<<i<<std::endl;
TOP = P.top();
P.pop();
NEXTtoTOP = P.top();
P.push(TOP);
}
std::cout<<"result<----------------"<<std::endl;
std::copy(Q.begin(), Q.end(), out);
return 0;
}
bool duplicatePoint(std::vector< Point_2 > &P, int pointPos, Point_2 &point)
{
for(int i = 0 ; i < pointPos ; i++)
if(P[i] == point)
return true;
return false;
}
bool cmp(const Point_2 &a, const Point_2 &b)
{
double aRad = findRad(a, P0);
double bRad = findRad(b, P0);
if(aRad < bRad)
return true;
if(aRad == bRad)
{
if(a.y() > b.y())
return true;
else if(a.y() == b.y() && a.x() > b.x())
return true;
else
return false;
}
return false;
}
double findRad(const Point_2 &P, const Point_2 &P0)
{
double dx, dy;
// Here is where I need P0 <-------------------------------------------------
dx = P.x() - P0.x();
dy = P.y() - P0.y();
if( dx == 0 && dy ==0 )
{
std::cout<< " In function findRad, atan result is UNDEFINED! Return 0! "$
return 0.0;
}
return( atan2(dx, dy) * (-1.00) );
}

There is an error when I call the stack, but I have fixed it in my latest version. Ignore the stack part