Code Highlight of Week: C++ Struct

A Struct is a basically a data structure similar to a model type of data. With this structure we can combine several primitive datatypes to create a new kind of datatype known as a structure.

Photo by Chris Ried on Unsplash

To define a struct we simple use the syntax struct followed by the name of the struct.

Next we can use primitive data types to occupy the struct to hold data. This is similar to using a class and defining properties for it.

Now that our struct has member variables in place, we can access them through memory by calling the (.) on the struct to access each variable like so:

Now let’s print to console and see what’s inside our struct:

Thanks for checking out my simple highlight on the struct datatype. Please feel free to connect for future project on github: blakewood84 and LinkedIn: https://www.linkedin.com/in/blakewoodjr/

--

--

<Blake†Codez />

I’m a Software Engineering student in Redding, Ca. Love all things Computer Science related, love for journalism, Jesus Christ, and team collaboration projects.