No, the runtime error occurs in the ACTUAL code that all of this must be pasted into.
I realize that there is STILL something wrong with my copy constructor, so I still need help.
class Club
{
public:
Club();
Club(Club &c);
Club(string cname);
Club(string cName, int nMember, string *aMember);//Added
//private: (Lazy@get_accessors@this)
string *members;
int numMembers;
string clubName;
};
//Empty Constructor
Club::Club()
{
clubName = "";
numMembers = 0;
//members = new string [numMembers]; //don't use new, unless necessary =O
}
//Copy Constructor
Club::Club(Club &c)
{
numMembers = c.numMembers;
members = c.members;//This works for me
clubName = c.clubName;
}
//Pre-initialized Constructor
Club::Club(string cName, int nMember, string *aMember){
clubName = cName;
numMembers = nMember;
members = aMember;//This works for me
}
//A simple function to test the data of an object type-Club
void print(const Club &a){
cout<<"Club Name: "<<a.clubName<<endl;
cout<<"Number of Members: "<<a.numMembers<<endl;
for(int i = 0; i < a.numMembers; i++){
cout<<"Member #"<<i<<": "<<a.members[i]<<endl;
}
}
int main()
{
string clubName="The only club";
int numberOfMembers = 4;
string members[] = {"Hydrogen","Oxygen","Nitrogen","Carbon"};
Club c(clubName,numberOfMembers,members);
Club d(c);
print(c);
print(d);
return 0;
}