20 Nov 2019

  • November 20, 2019
  • Amitraj
Structure of a C++ Program
     
1.) Header file (Include file)
2.) Member function definition
3.) Class declaration
4.) Main function


1. Header File:
In this section, we add header files and resource files. These files provide definition for function and object used in a program.



2. Member Function Definition:
In this section class member, function and other functions are defined.
Ex:

demo :: fun()
{
            Definition
}



3. Class Declaration:
In this area class is defined.
Ex:

class demo
{
            Member variables and functions
};



4. Main Function:
This is special type of function that is called at the beginning of program execution. Each program must have one main function.

int  main()
{
            return 0;
}

Related Posts:

  • Exception Handling in C++ Exception Handling in C++ -> We often come across some peculiar problems other than logic or syntax error. They are known as exceptions. -> Exceptions are run time anomalies(errors) or unusual conditions that A progr… Read More
  • Rethrowing an Exception in C++ Rethrowing an Exception in C++ -> A handler may decide to rethrow the exception caught without processing it. In such situations, we may simply invoke throw without any arguments as shown below:       thro… Read More
  • Exception Handling Mechanism in C++ ( throwing an exception, the try block, catching an exception ) Exception Handling Mechanism in C++ -> C++ exception handling mechanism is basically built upon 3 keywords namely  try, throw and catch. -> The keyword try is used to preface a block of statements which may gene… Read More
  • Exception objects in C++ Exception objects The exception object is available only in catch block. You cannot use the exception object outside the catch block. Following steps happen when you throw an exception and catch: try {  MyException … Read More
  • Catch All Exceptions in C++ Catch All Exceptions in C++ -> In some situations, we may not be able to anticipate types of exceptions and therefore may not be able to design independent catch handlers to catch them. In such circumstances, we can forc… Read More

Translate

Popular Posts