Daniel T. Williams

+ Follow
since Sep 21, 2013
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Daniel T. Williams

I have an assignment to work on that I don't understand. Would appreciate any assistance to get me headed in the right direction. The instructions for this are:

Define a structure Student with a name and a vector<Course*> of courses.
• Define a structure Course with a name and a vector<Student*> of enrolled students.
• Define a function void print_student(Student* s) that print the name of a student and the names of all courses that the student takes.
• Define a function void print_course(Course* c) the prints the name of a course and the names of all students in that course.
• Define a function void enroll(Student* s, Course* c) that enrolls the given student in the given course, updating both vectors.
Note: because the Student structure refers to Course, and Course refers to Student, you'll need to use a structure declaration (aka—a forward reference) to allow you to write the definitions in the header file.

This is what I have in my header file:

In my .cpp file this is what I have:

I'm using Visual Studio 2013 and I can't get anything to compile. I'm not even sure what to do, any help would be appreciated. Thank you.
10 years ago
I have tried blanking the name variable but that hasn't done anything. Every time it will ask the user for "The appointment time to be entered". I tried stepping through each line of code and the string that causes the error, it gets added to the name variable once it loops back and starts over again.
10 years ago
Hello, I'm pretty new to this and I'm trying to learn exception handling right now. This is part of an assignment I'm working on but the problem I'm running into is with the second prompt. When the user enters a time, if it is a string it should throw an exception, it does do this but when the loop starts again the string gets stored in the name variable which I don't want. Any thoughts or suggestions would be appreciated. Thank you.

10 years ago

Campbell Ritchie wrote:Welcome to the Ranch

Have you been told to use that technique for sorting objects? It looks very cumbersome, particularly when there are many sorting algorithms available. Also, have you really been taught to use such a long main() method?

Thank you for the welcome

The main method is part of a template that the instructor wants us to use on each project we do.

Campbell Ritchie wrote:@Daniel: And what happens if next time you have 4 Strings to sort? Or 5? Or 500? Do you propose to write the entire process out in longhand then?

If this is simply an exercise in logic (and if so, it's not a bad one), then one thing that might help is to write out a truth table. That at least should help you to cover all bases.

I'm pretty sure this assignment was just an excerise in logic as you suggested. In fact I did end up using a truth table later to figure this out. In the upcoming weeks we will be doing switch statements and then arrays, so these things should be easier. Thanks for the help.
10 years ago
I figured it was something simple that I wasn't seeing. Sometimes it is helpful to have another set of eyes look at it. Thank you.
10 years ago
Hello. I'm trying to sort 3 strings entered by a user in alphabetic order.
It works fine until the last else if statement and will only print 2 of the strings.
This is a project for school and the instructor wants us to use If/else statements right now as we haven't gotten to arrays.
Any help on why the last statement only prints 2 strings would be appreciated. Thank you.

10 years ago