Need help please!!! I am stuck

Hi! I am quite new in OOP. I understand the basics and I can create a simple class. But when i get a task to create some class like this one I do not know where to start and what to do first. I would be grateful if someone could help me with this one. I have started codding this but every time I write a private section and do not know what to do (and how for some things) next.

Create the MACAdress class that needs to compile a six bytes sequence, which are initialized by instantiating objects in this class. Default values of array are 0, but we must not set them in constructor. That must be forbidden. This class must have an option to incialize elements of array by constructor with one parameter, example parameter can be some array. The class should support a mechanism that allows two of its objects to be compared to equality, if a1 and a2 are instances of this class, then a1 == a2 should be allowed. Also, the address input in the output stream (std :: cout << address;) in this format should be enabled: hex: hex: hex: hex: hex: hex, where hex designates the byte value written in the hexadecimal system.

Thank you in advance!
Last edited on
If you are REALLY new to C++ and object oriented programming, this task is way too far into the study for a beginner. That's why you're having trouble.

Is this from a book or from a course you're taking?

For example, have you already studied operator overloads in classes?

Last edited on
Yes this is from a course and I am familiar with operator overloading. I have theoretical
knowledge and a big problem with implementation with problems like this. I do some without any trouble, but not ones like this.(maybe notation is the problem) That is why I have asked for help for this particular problem.
Last edited on
Create the MACAdress [sic] class
1
2
3
class MACAdress {

};


Default values of array are 0, but we must not set them in constructor. That must be forbidden.

No idea what this means. Perhaps
1
2
3
4
5
6
using byte = unsigned char;

class MACAdress {
  public:
    byte arr[6] = {};
};


This class must have an option to incialize elements of array by constructor with one parameter, example parameter can be some array.
1
2
3
4
5
6
7
8
9
10
11
12
13
using byte = unsigned char;

class MACAdress {
  public:
    MACAdress(byte other_arr[])
    {
        for (int i = 0; i < 6; i++)
        {
            arr[i] = other_arr[i];
        }
    }
    byte arr[6] = {};
};


If you have questions, you will get more help if you ask about specific issues that you're having. If you have no idea where to start, then I suggest going to the site's tutorial http://www.cplusplus.com/doc/tutorial/, or another site's tutorial like GeeksForGeeks.
Last edited on
Topic archived. No new replies allowed.