
May 21st, 2003, 08:45 AM
|
 |
/(bb|[^b]{2})/
|
|
Join Date: Nov 2001
Location: Somewhere in the great unknown
|
|
Here is what I come up with (using VC++ 6)
This compiled and worked as expected.
PHP Code:
#include <iostream>
#include <string.h>
using namespace std;
class athlete {
protected:
char *firstname;
char *lastname;
char *team;
int jersey;
int gplayed;
public:
athlete(const char*, const char*, const char*, int=0, int=0);
~athlete();
virtual void calcFigs()const=0;
};
athlete::athlete(const char *first , const char *last , const char *team1, int j, int g) {
athlete::firstname = new char[strlen(first) + 1];
strcpy(athlete::firstname, first);
athlete::lastname = new char[strlen(last) + 1];
strcpy(athlete::lastname, last);
athlete::team = new char[strlen(team1) + 1];
strcpy(athlete::team, team1);
athlete::jersey=j;
athlete::gplayed=g;
}
athlete::~athlete() {
delete [] athlete::firstname;
delete [] athlete::lastname;
delete [] athlete::team;
}
class bball : public athlete {
public:
bball(const char*, const char*, const char*, int=0, int=0, int=0, int=0, int=0);
virtual void calcFigs()const;
private:
int rebounds;
int assists;
int points;
};
bball::bball(const char *first, const char *last, const char *team1, int jr, int gpl, int reb,
int ast, int poi) : athlete(first , last , team1) {
bball::jersey=jr;
bball::gplayed=gpl;
bball::rebounds=reb;
bball::assists=ast;
bball::points=poi;
}
void bball::calcFigs()const {
float avgp, avga, avgr ;
avgp = (points/gplayed);
avga = (assists/gplayed);
avgr = (rebounds/gplayed);
cout << bball::firstname << " " << bball::lastname << " for " << bball::team << endl;
cout << "Average Points: " << avgp << endl;
cout << "Average Assists: " << avga << endl;
cout << "Average Rebounds: " << avgr << endl;
}
int main() {
bball J("M","J","Chicago",24,2,12,20,32);
J.calcFigs();
getchar();
return 1;
}
|