private:

GradedActivity *grades[NUM_GRADES];

public:

void setLab(GradedActivity *activity)
    { grades[LAB] = activity; }

Totally confused with this one.

If you mean UML diagram, then get Sparx Enterprise Architect and use its reverse engineering capabilities to convert code to UML.

first of all , you need to understand the parts of UML diagrams ,
we have actor , use case , and relationships (for more info search the net)

actors are persons or other softwares/hardwares working with this software

use cases indicate the uses of a program in total , you should ask yourself what does this program do for the actors , then start painting them .

now in order to understand and be able to write a UML diagram you should look into some samples

here take a look => https://www.google.co.uk/search?q=UML+Samples&es_sm=93&source=lnms&tbm=isch&sa=X&ei=sJFvU6z8BsKbPcKdgZAP&ved=0CAgQ_AUoAQ&biw=1680&bih=925

I just need to know how to create a class diagram for that particular class... similar to this:

Attachments Screen_Shot_2014-05-10_at_10.04_.56_PM_.png 23.83 KB

Did I do it right here?
I've attached my UML diagram. Please let me know if it's right or wrong.

class CourseGrades
{
private:
    // Array of GradedActivity pointers to
    // reference the different types of grades
    GradedActivity *grades[NUM_GRADES];

public:
    // Default constructor
    CourseGrades()
    { for (int i = 0; i < NUM_GRADES; i++)
         grades[i] = NULL;
    }

    // Mutators
    void setLab(GradedActivity *activity)
        { grades[LAB] = activity; }

    void setPassFailExam(PassFailExam *pfexam)
        { grades[PASS_FAIL_EXAM] = pfexam; }


    void setFinalExam(FinalExam *finalExam)
        { grades[FINAL_EXAM] = finalExam; }

    // print function
    void print() const;
};

Edited 2 Years Ago by glamiex: added an attachment

Attachments Screen_Shot_2014-05-11_at_9.22_.09_AM_.png 27.77 KB

That looks pretty correct. You do need an enum to define indexes into grades such as LAB, PASS_FAIL_EXAM, FINAL_EXAM, etc. At least it looks like that's what you need.

This article has been dead for over six months. Start a new discussion instead.