Structure of C++ Program

 


How to write Program in C++ ?

The answer is in two ways

  1. Function Definition Inside class declaration(Function within class)
  2. Function Definition Outside class declaration  (Function  & class  declared separated )
Inside DefinitionOutside Definition
Link with System LibraryLink with System Library
Class declaration with Member Function DefinitionClass declaration
Member Function Definition

 

A typical C++ program would contain four sections . These sections may be placed in separate code files and then compiled independently or jointly.

It is a common practice to organize a program into three separate files. The class declarations are placed in a header file and the definitions of member functions go into another file.

Finally, the main program that uses the class is placed in a third file which “includes” the previous two files as well as any other files required


C++ Inside Definition Program

Output of Inside Definition

Enter your Name : Mohan

Enter your Number : 123

Name = Mohan

No = 123


C++ Outside Definition Program

Output of  Outside Definition

Enter your Name : Mohan

Enter your Number : 123

Name = Mohan

No = 123

(Visited 61 times, 1 visits today)

Leave a Reply

Your email address will not be published. Required fields are marked *


CAPTCHA Image
Reload Image