need help

A university wants to develop an application that will manage its student’s records. Application will store student’s personal information like registration no., name, address, current semester, study program and CGPA. University wishes that no other application should have full access to their student’s information except what they want to show to the other applications.

If you are positioned as a programmer to program this application, which programming construct you will adopt; “Class” or “Structure (Struct)”?

Justify your answer with logical reasons. Clear and concise comments are suggested.


Google "C++ information hiding"
A university wants to develop an application that will manage its student’s records. Application will store student’s personal information like registration no., name, address, current semester, study program and CGPA. University wishes that no other application should have full access to their student’s information except what they want to show to the other applications.

If you are positioned as a programmer to program this application, which programming construct you will adopt; “Class” or “Structure (Struct)”?

Justify your answer with logical reasons. Clear and concise comments are suggested.


Structs in C++ have the same usage as classes in C++. The only difference being that structs will expose their members as public by default whereas class members are private by default.

1
2
3
4
5
6
7
struct Student {
    float gpa; // public
};

class Student {
    float gpa; // private
};


See: https://stackoverflow.com/a/54596/2089675
Last edited on
well
yo can still use
1
2
3
4
5
6
7
8
9
10
11
struct Student
{
 private :
     float gpa
}

class Student
{
public :
     float gpa;
}


but generally struct is used for simple data
Topic archived. No new replies allowed.