What is a Struct?

I keep hearing mentions of structs but I am unaware of what a Struct actually is.

2 Likes

A STRUCT is a C++ data structure that can be used to store together elements of different data types. And later you can call by using some specific syntax

Example of struct:-

struct Person
{
char name[30];
int citizenship;
int age;
}

Above in the example we are storing different data type related to a person.

2 Likes

In, regular, C++ a struct is exactly the same like a class. With the only difference being that the access specifier to member variables and functions is public by default, whereas this is private for a class. You usually see them being used as data containers.

3 Likes

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms