Thread: Class Array
View Single Post
Old 05-11-2004, 02:29 AM   #6 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,726
redhead is on a distinguished road
Quote:
Originally posted by kokkines
Thanks. How would I go about doing that?
Remove the Planet A[5]; from the void Planet::find() Since you're declaring A as Planet class within the main you shouldn't need to declare it within it's own find function.

On a closer look, it seems your Planet class definition won't work with this sort of find() function.

Code:
class Planet
{
  private:
  string name;
  float radius;
  float median;
public:
  /* create functions to deal with any type of "decleration" */
  bool Planet();
  bool Planet(string name);
  bool Planet(string name, float radius); 
  bool Planet(string name, float radius, float median);  
  /* delete function */
  bool ~Planet(); 
  float sa();
  float den();
  void output();
  void outputaf();
};

bool Planet::Planet()
{ 
return (this.name = "" && 
        this.radius = 0.0 && 
        this.median = 0.0);
}
bool Planet::Planet(string name)
{ 
return (this.name = name && 
        this.radius = 0.0 && 
        this.median = 0.0);
}
bool Planet::Planet(string name, float radius)
{ 
return (this.name = name && 
        this.radius = radius && 
        this.median = 0.0);
}
bool Planet::Planet(string name, float radius, float median)
{ 
return (this.name = name && 
        this.radius = radius && 
        this.median = median);
}
bool Planet::~Planet()
{ 
return (this.name = "" && 
        this.radius = 0.0 && 
        this.median = 0.0);
}
float Planet::sa()
{
  return pow(this.radius,2)*4*M_PI;
}
float Planet::den()
{
  return (this.median/(pow(this.radius,3)*M_PI*4/3));
}

class Planets
{
private:
  vector<Planet> P
public:
  bool sort();
  bool add();
  bool del();
  void find();
}
might be a better aproach.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote