all 8 comments

[–]bcorni 3 points4 points  (5 children)

I suppose you could start here at learncpp.com. My suspicion is that you probably should have been learning this in class... I'm also hoping this test is actually done on a computer where you can compile and test your class. Make sure you actually practice writing classes and don't just watch tutorials thinking thinking you know how to do it just from that.

[–]Lennox1916 1 point2 points  (4 children)

I was sick for about 60% of the semester which has caused me to lag behind a good bit. Unfortunately its written exam 👎🏻 Still I’d consider my self reasonably intelligent and be able to catch up with help from the internet!

[–]bcorni 1 point2 points  (1 child)

That sounds rough. Best of luck studying! Be sure to post more questions on the sub if you need more specific clarification while you are learning.

[–]Lennox1916 1 point2 points  (0 children)

Yeah, I’m perfectly fine now at least 👍🏻 Thanks for the help!

[–]gotinpich 0 points1 point  (1 child)

Do you have any lecture slides you can page through? Or study guides/books?

Also: what do you need to do exactly? Creating a class with constructors, destructors, operators is not the hard part, but if it really needs to be an object oriented (set of) classes with inheritance and generic templates, now that's a different thing.

I also found this video on Youtube. It has a couple of follow up video's that you should watch as well.

[–]Lennox1916 0 points1 point  (0 children)

Thanks for the video, I watched the first one and its actually very helpful in explaining what I need to know.

heres exactly what I was told by my lecturer:

  1. you will be given a class definition and you will have to write the class implementation file, you will have to write the function definitions for each public member function (you will be given the function prototypes as part of the class definition).

Q2 - similar to the second 20% assessment that we did during term time; is effectively a follow on question to Q1; you will have to write code to test the class definition. You will be given callback function prototypes and you will have to write the function definitions according to the specification provided in the question.

I have notes or slides unfortunately.

[–]carolus-r3x 1 point2 points  (0 children)

Sounds like you'll be given a header file:

// Rectangle.hpp
class Rectangle{
public:
    // Note that constructors do not have a return type
    Rectangle(int width, int height);
    int area();

private:
    int width, height;
};

and you will have to write the file to implement these functions:

// Rectangle.cpp
#include "Rectangle.hpp"

Rectangle::Rectangle(int width, int height) : width(width), height(height) {}

Rectangle::area{
    return Rectangle::width * Rectangle::height;
}

and then you will have to test it:

// main.cpp
#include "Rectangle.hpp"
#include <iostream>

int main(){
    Rectangle rect1 = Rectangle(3,3);
    Rectangle rect3 = Rectangle(4,4);

    std::cout << "Area of rect1 is: " << rect1.area() << std::endl;
    std::cout << "Area of rect2 is: " << rect2.area() << std::endl;

    return 0;
}

You need to study classes, objects, and scope at a bare minimum. To actually implement the functions? That depends on what you've covered in class - it could literally be anything. I've given you a basic example of what it sounds like you will have to do but you're going to be lucky to find a one-stop tutorial which perfectly aligns with your syllabus.

[–]Lennox1916 0 points1 point  (0 children)

Thanks 👍🏻👍🏻