Tuesday 12 February 2013

Structre in C++ Programming Languages



A structure is defined as a data type to represent different types of data with a single name. The data items in a structure are called members of the structure.

Defining a structure:

A structure definition contains a keyword struct and a user defined tag-field followed by the members of the structure within braces. The general form is

struct tag-field
{
datatype member1;
datatype member2;
-------
-------
datatype membern;
}

where,
struct  - keyword to define structure
tag-field - name of the structure - valid C++ name
datatype - valid datatypes such as int, float etc

Steps and Rules:

1. Tag-field is the name given to the structure
2. Each member definition should be terminated with semicolon
3. Since structure definition has compound statements, it should have its own opening and closing braces.
4. The semicolon after the closing brace is a must.

0 comments:

Post a Comment

Powered by Blogger.