Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Why this can be compiled successfully?

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Why this can be compiled successfully?


Chronological Thread 
  • From: "Laurent Rineau (GeometryFactory)" <>
  • To:
  • Subject: Re: [cgal-discuss] Why this can be compiled successfully?
  • Date: Thu, 30 Jun 2011 17:08:34 +0200
  • Organization: GeometryFactory

On jeudi 30 juin 2011 16:58:16 updog wrote:
> #include <iostream>
> #include <fstream>
> #include &lt;CGAL/Cartesian.h&gt;
> #include &lt;CGAL/squared_distance_3.h&gt;
> #include &lt;CGAL/Point_3.h&gt;
> typedef CGAL::Point_3< CGAL::Cartesian<double> > Point;
>
> using std::cout;
> using std::endl;
>
> int main() {
> Point p1, p2;
> double x = squared_distance(p1, p2);
> cout << x << endl;
> return 0;
> }
>
> Note that I forgot to place "CGAL::" before squared_distance(p1,p2), why
> this still can be compiled?

It is a feature of C++:
http://en.wikipedia.org/wiki/Argument-dependent_name_lookup

p1 and p2 are objects of types in the CGAL namespace, and name lookup for
squared_distance searches in that namespace too.

--
Laurent Rineau, PhD
R&D Engineer at GeometryFactory http://www.geometryfactory.com/
Release Manager of the CGAL Project http://www.cgal.org/



Archive powered by MHonArc 2.6.16.

Top of Page