Home | | Object Oriented Programming and Data Structures | The structure of a C++ program

Chapter: Object Oriented Programming and Data Structure : Data Abstraction & Overloading

The structure of a C++ program

A comment istext that is ignored by the compiler but which nonetheless conveys information to other programmers. A comment consists of text enclosed between the markers /* and */ and may continue over several lines.

The structure of a C++ program

A comment istext that is ignored by the compiler but which nonetheless conveys information to other programmers. A comment consists of text enclosed between the markers /* and */ and may continue over several lines.

 

The lines beginning with #include such as

 

#include "genlib.h" 

#include <iostream> 

#include <iomanip>

 

indicate that the compiler should read in definitions from a header file. The inclusion of a header file indicates that the program uses facilities from a library, which is a collection of prewritten tools that perform a set of useful operations.

 

Program-level definitions const type name = value ; constint LOWER_LIMIT = 0; constint UPPER_LIMIT = 12;

 

A function is a unit of code that (1) performs a specific operation and (2) is identified by name. intRaiseIntToPower(int n, int k); is an example of a function prototype, a declaration that tells the compiler the information it needs to know about a function to generate the proper code when that function is invoked.

 

The main program

Every C++ program must contain a function with the name main. This function specifies the starting point for the computation and is called when the program starts up. When main has finished its work and returns, execution of the program ends.

 

The next line in the body of RaiseIntToPoweris

 

result = 1;

This statement is a simple example of an assignment statement, which sets the variable on the left of the equal sign to the value of the expression on the right.


Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail
Object Oriented Programming and Data Structure : Data Abstraction & Overloading : The structure of a C++ program |


Privacy Policy, Terms and Conditions, DMCA Policy and Compliant

Copyright © 2018-2024 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.