Structures are the same as classes in C++. The only difference is that structure members are public by default while class members are private by default, but both define a class of object and both are initialised via a class constructor initialisation list.
struct my_object
{
my_object(const int data): m_data(data) {}
private:
int m_data;
};
The above struct is no different to the following class:
class my_object
{
int m_data;
public:
my_object(const int data): m_data(data) {}
};
Copyright © 2026 eLLeNow.com All Rights Reserved.