newb question: need help with homework assignment
From: don't know (I'mat_at_nowhere.com)
Date: 05/29/04
- Next message: Mike Wahler: "Re: newb question: need help with homework assignment"
- Previous message: Scott: "Re: forward declaration error"
- Next in thread: Mike Wahler: "Re: newb question: need help with homework assignment"
- Reply: Mike Wahler: "Re: newb question: need help with homework assignment"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 29 May 2004 11:59:54 -0400
Hi,
I have been working on this assignment(with the help of my instructor, she
told me this was ok) and cannot figure out why it doesn't display to the
screen. (She didn't know why either).
Can someone tell me why it doesn't display to the screen? Is it because the
showWork function is in the wrong place?
Thank You,
a frustrated newb
template<class T>
T AddTwo(T x, T y)
{
T totalMinutes;
totalMinutes = x + y;
return (totalMinutes);
}
class Homework
{
private:
char className[50];
char assignment[50];
int minutes;
int totalMinutes;
public:
void SetValues(char classNm[], char assign[], int time);
void showWork();
Homework operator+(Homework h);
};
void Homework::SetValues(char classNm[], char assign[], int time)
{
strcpy(className, classNm);
strcpy(assignment, assign);
minutes = time;
}
void Homework::showWork()
{
cout<<"Homework assignment "<<assignment<<" for "<<className<<" should take
approximately "<<minutes<<endl;
}
Homework Homework::operator +(Homework h)
{
Homework temp;
strcpy(temp.className, "Total Homework");
strcpy(temp.assignment, "Total Assignment");
temp.minutes = minutes + h.minutes;
return (temp);
}
void main()
{
int a, b, c;
a = 15;
b = 25;
c = AddTwo(a,b);
double g, h, i;
g = 5.15;
h = 4.15;
i = AddTwo(g,h);
Homework j, k, l;
j.SetValues("CS218", "Read Chapter 11", 25);
k.SetValues("CS310", "Homework: Exercise 12 Page 411", 40);
l = AddTwo(j,k);
void showWork();
getch();
}
- Next message: Mike Wahler: "Re: newb question: need help with homework assignment"
- Previous message: Scott: "Re: forward declaration error"
- Next in thread: Mike Wahler: "Re: newb question: need help with homework assignment"
- Reply: Mike Wahler: "Re: newb question: need help with homework assignment"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|