Sphcirc.h: troubled C++ newbie seeks next step help


jmbl49
06-16-2009, 01:39 PM
I've constructed a driver for sphcirc.h and saved it as sphcirc.cpp.

#include "nr3.h"
#include "pointbox.h"
#include "sphcirc.h"

int main()
{

/*
I've figured out WHAT "Point" is and can safely say that I have a center for my sphere:
/*

Point<3> cent(0,0,0);

/*
And naturally, the radius is simple enough so I've added that to my int Main() as well:
*/

Doub rad = 21;

/*
Now ... can someone please direct me to correctsville with respect to initializing Sphcirc:
*/

... Sphcirc(cent, rad) ... (VS8.0: error C2955: 'Sphrcirc : use of class template requires template argument list )

Save me?

davekw7x
06-16-2009, 02:24 PM
...driver for sphcirc...

//
// davekw7x
//

#include "../code/nr3.h"
#include "../code/pointbox.h"
#include "../code/sphcirc.h"

int main()
{
Doub x, y, z;
Point<3> cent(0,0,0); // 3-D point
Doub rad = 21;
Sphcirc<3> mySphere(cent, rad); // Sphere has DIM = 3

cout << "Enter x y z: ";
while (cin >> x >> y >> z) {
Point <3> thePoint(x, y, z);
cout << "The sphere ";
if (mySphere.contains(thePoint)) {
cout << "contains";
}
else {
cout << "does not contain";
}
cout << " the point (" << x << "," << y << "," << z << ")"
<< endl << endl;

cout << "Enter x y z: ";
}

cout << endl << "Goodbye for now." << endl;

return 0;
}


A run:

Enter x y z: 1 1 1
The sphere contains the point (1,1,1)

Enter x y z: 12.1 12.1 12.1
The sphere contains the point (12.1,12.1,12.1)

Enter x y z: 12.2 12.2 12.2
The sphere does not contain the point (12.2,12.2,12.2)

Enter x y z: quit

Goodbye for now.


Regards,

Dave

jmbl49
06-18-2009, 02:09 PM
You've used the "contains" apparatus as well as pointed out where my doomed engram was taking me. Shades of relief 'fer now!