Embed presentation
Download to read offline



![10
5. Creating New Data Types in C++
struct Name {
char first[10];
char last[10];
};
In C,
struct Name stdname;
In C++,
Name stdname;
The same is true for enums and unions](https://image.slidesharecdn.com/lo17-160512122324/75/Lo17-4-2048.jpg)
Declarations in C++ can be placed anywhere except in conditions of control structures like if, while, and for statements. An example shows declaring and initializing two integer variables x and y within a program that gets user input, performs a calculation, and outputs a result. Structs can be used to create new data types in C++, with an example given of a Name struct containing first and last character arrays and declaring a variable of the Name type both with and without the struct keyword.



![10
5. Creating New Data Types in C++
struct Name {
char first[10];
char last[10];
};
In C,
struct Name stdname;
In C++,
Name stdname;
The same is true for enums and unions](https://image.slidesharecdn.com/lo17-160512122324/75/Lo17-4-2048.jpg)