x.Hm want the destructor to delete the memory allocated for the \"groupname\" bu
ID: 3615571 • Letter: X
Question
x.Hm want the destructor to delete the memory allocated for the "groupname" but I think I'm doing it wrong because I got some strange output when I execute the program. Pls can you fix it for me? thanks.4 88 11.30 a 10/10 L 10.00 45 The Big Event
8 120 6.00 p 10/9 S 15.00 40 Oozeball
490 34 12.30 p 10/12 V 25.00 40 Society of Women Engineers
130 32 11.30 a 8/10 F 10.00 30 Joint Council of Eng. Organs.
132 43 12.00 p 10/13 P 15.00 55 Freshman Leaders on Campus
134 18 1.00 p 10/19 M 5.00 45 National Society of Black engs.
135 90 9.00 a 11/14 C 4.00 40 Society of Professional Engs.
170 91 10.00 p 10/11 F 6.00 35 Biomedical Eng. Student Society
512 15 9.30 a 12/12 C 15.00 40 Concert choir
140 36 12.00 p 10/15 L 5.00 45 Assoc. for Computing Machinery
141 45 2.30 p 10/21 V 15.00 58 Game Developer's Club
#include<fstream>
#include<iostream>
#include<string>
#include<cstdlib>
#define GROUPMAX 50
using namespace std;
class Activities
{
public:
Activities();
void setgroupNum(int num);
void setgroupSize(int size);
void setgroupTime(float time);
void setgrouphfDay(char hfday);
void setgroupMonth(int month);
void setgroupDay(int day);
void setgroupPurpose(char pose);
void setgroupCost(float cost);
void setgroupLength(int len);
void setgroupName(char name[]);
int getgroupNum();
char * getgroupName();
float getmeetTime();
char gethalfDay();
int getmeetMonth();
int getmeetDay();
char getgroupPurpose();
int getgroupSize();
float getgroupCost();
int getmeetLength();
~Activities();
private:
int groupnum;
char *groupname;
float meettime;
char mthalfday;
int nextmonth;
int nextday;
char purpose;
int groupsize;
float groupcost;
int meetlength;
};
Activities::Activities()
{
groupnum = 0;
groupname = "";
meettime = 0.0;
mthalfday = '';
nextmonth = 0;
nextday = 0;
purpose = '';
groupsize = 0;
groupcost = 0.0;
meetlength = 0;
}
void Activities::setgroupNum(int num)
{
groupnum = num;
}
void Activities::setgroupSize(int size)
{
groupsize = size;
}
void Activities::setgroupTime(float time)
{
meettime = time;
}
void Activities::setgrouphfDay(char hfday)
{
mthalfday = hfday;
}
void Activities::setgroupMonth(int month)
{
nextmonth = month;
}
void Activities::setgroupDay(int day)
{
nextday = day;
}
void Activities::setgroupPurpose(char pose)
{
purpose = pose;
}
void Activities::setgroupCost(float cost)
{
groupcost = cost;
}
void Activities::setgroupLength(int len)
{
meetlength = len;
}
void Activities::setgroupName(char name[])
{
groupname = new char[strlen(name) + 1];
strcpy(groupname, name);
}
int Activities::getgroupNum()
{
return groupnum;
}
int Activities::getgroupSize()
{
return groupsize;
}
int Activities::getmeetMonth()
{
return nextmonth;
}
int Activities::getmeetDay()
{
return nextday;
}
int Activities::getmeetLength()
{
return meetlength;
}
float Activities::getmeetTime()
{
return meettime;
}
float Activities::getgroupCost()
{
return groupcost;
}
char Activities::gethalfDay()
{
return mthalfday;
}
char Activities::getgroupPurpose()
{
return purpose;
}
char * Activities::getgroupName()
{
return groupname;
}
Activities::~Activities()
{
delete groupname;
}
void printallinput(Activities fungroup[], int xindex);
void searchmeettime(Activities fungroup[], int xindex);
void bubblesortgroupnum(Activities fungroup[], int xindex);
int main(void)
{
Activities TAorg[GROUPMAX];
int i, index = 0, intro;
int old, mnum, msize;
int mmonth, mday, mlen;
float mcost, mtime;
const int MAX = 100;
char mhalf, namestr[MAX];
char mpose;
int choose;
int meettemp;
cout << " Welcome to Campus Activities system; also known as CAS.";
Explanation / Answer
x.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.