Tuesday, September 1, 2020

C# (Windows Form)

 

Introduction:

In C#, the form is the container for all the controls that make up the user interface. When a C# application is executing, each window it displays on the desktop is a form.

Every C# application starts with the form. Forms have built-in functionality that is always available without any programming effort. You can move a form around, resize it, and even cover it with other forms. You can do this with the mouse, or with the keyboard through the Control menu.

The forms that compose the visible interface of your application are called Windows forms. A dialog box is a form with a small number of controls, no menus, and usually an OK and a Cancel button to close it.

The Appearance of the Form


Applications are made up of one or more forms, and the forms are what users see. A windows form can be viewed as shown in figure.

 Clicking the icon on the top left of the title bar opens the Control menu, which contains the commands to Minimize, Restore, Maximize, Move and Close a form. The top right of the title bar contains three buttons: Minimize, Maximize, and Close. Clicking these buttons performs the associated function. When a form is maximized, the Maximize button is replaced by the Restore button. When clicked, this button resets the form to the size and position before it was maximized. The Restore button is then replaced by the Maximize button.

 Properties of the form

 The properties of a form are used to change the appearance of the form. By using the properties you can change the title of a form, background color of a form, position of the form on console, appearance of minimize, maximize button and so on.

 To change the properties of a form you have to visit the property window by pressing F4 key from keyboard or by clicking on the property window button on standard toolbar of C#.

 Here are some for the important properties of form.

Property

Description

BackColor

This property is used to sets or to get the background color for this form.

BackgroundImage

This property is used to sets or to get the background image in the form.

ControlBox

This is a Boolean property, having one of values TRUE or FALSE. TRUE value indicates that Control Box is displayed and active, where as FALSE value indicates that Control Box is get removed form the form.

Enabled

This is a Boolean property, having one of values TRUE or FALSE. TRUE means the form is Enabled i.e. all controls on form are in working. FALSE means all control on the form are not in working.

ForeColor

This property is used to set forecolor to the form.

FormBorderStyle

This property determines the style of the form’s border and the appearance of the form. This property has different property values some of the property values are 

Property Value                                                Purpose

None                            Borderless window that can’t be resized; this setting 

                                     should be avoided.

Sizable (default)        Resizable window that’s used for displaying regular forms.

Fixed3D                     Window with a visible border, “raised” relative to the 

                                     main area. Can’t be resized.

MaximizeBox

Is used to active or inactive the Maximize button on Title bar. It is Boolean Property.

MinimizeBox

Is used to active or inactive the Minimize button on Title bar. It is Boolean Property.

Name

This property is used to give name to the form. This property value is being used while writing a program.

ShowInTaskbar

Is used to decide whether a form is to be display on the Taskbar or not. It is Boolean Property.

StartPosition

This property determines the initial position of the form when it’s first displayed; it can have one of the following values.

Value                                      Effect

CenterParent                The form is centered in the area of its parent form.

CenterScreen               The form is centered on the monitor.

Manual                      The location and size of the form will determine its starting                                     position.

WindowsDefaultBounds  The form is positioned at the default location and size determined by Windows.

WindowsDefaultLocation The form is positioned at the Windows default location and has the dimensions you’ve set at design time.

Text

This property is used to Display name of Form on Title bar for user interaction purpose.

WindowState

This property is used to determine the state of window form while it is executing. This property has different property values.


 
Anchoring & Docking

One of the most tedious tasks in designing user interfaces with C# was the proper arrangement of the controls on the form, especially on forms that users were allowed to resize at runtime. You design a nice form for a given size, and when it’s resized at runtime, the controls are all clustered in the top-left corner. A TextBox control that covered the entire width of the form at design time suddenly shrink on the left when the user drags out the window.

The Anchor and Dock properties of the various controls allow you specify how they will be arranged with respect to the edges of the form when the user resizes it.

The Anchor property lets you attach one or more edges of the control to corresponding edges of the form. The anchored edges of the control maintain the same distance from the corresponding edges of the form. Place a TextBox control on a new form and then open the control’s Anchor property in the Properties window. You will see a little square within a larger square, and four pegs (hanger) that connect the small control to the sides of the larger box. The large box is the form, and the small one is the control. The four pegs are the anchors, which can be either white or gray. The gray anchors denote a fixed distance between the control and the form. By default, the control is placed at a fixed distance from the top-left corner of the form. When the form is resized, the control retains its size and its distance from the top-left corner of the form.

In addition to the Anchor property, most controls provide the Dock property, which determines how a control will dock on the form. The default value of this property is None.

Create a new form, place a TextBox control on it, and then open the control’s Dock property. The various rectangular shapes are the settings of the property. If you click the middle rectangle, the control will be docked over the entire form: it will expand and shrink both horizontally and vertically to cover the entire form. This setting is appropriate for simple forms that contain a single control, usually a TextBox, and sometimes a menu.

 


The Form Events

 

 Event is an action performed by user, e.g. moving a mouse, pressing a key on keyboard, selecting a control on form.

 

C# supports several event functions depending upon the user’s action. As a form can be minimized, maximized, closed, activated and so on, to handle all these actions of a form C# supports several methods k/as events of a form.

 

Following are some of the important events of a form.

 

1) Load Event :

 

This event occurs before a form is displayed for the first time. This is default event of a form. This event is used to perform buildup operation on variables. This event is fired when the user executes the form by clicking on run button or by pressing F5 key from keyboard. When this event fires it loads all necessary items required in to memory.

The general form of load event is

 

private void Form1_Load(object sender, EventArgs e)

        {

        }

 

2) Activated:

 

This event occurs when the form is activated in code or by the user. This event occurred immediately after the Load event.

 The general form of this event is

private void Form1_Activated(object sender, EventArgs e)

        {

        }

 

 

3) Click :

 

This event occurs when the form is clicked by user.

private void Form1_Click(object sender, EventArgs e)

        {

        }

 


5) FormClosing :

 

This event is fired when the user closes the form by clicking its Close button and the application is in closing procedure.

private void Form1_FormClosing(object sender, FormClosingEventArgs e)

        {

        }

 

4) FormClosed :

 

This event is fired when the user closes the form by clicking its Close button and the application is closed.

 

private void Form1_FormClosed(object sender, FormClosedEventArgs e)

        {

        }

 

Loading and Showing Forms

One of the operations you’ll have to perform with multi-form applications is to load and manipulate forms from within other forms’ code. To access a form from within another form, you must first create a variable that references the second form. If your application has two forms, named Form1 and Form2, and that Form1 is the project’s startup form. To show Form2 when an action takes place on Form1, first declare a variable that references Form2:

Form1 frm = new Form1();

This declaration must appear in Form1 and must be placed outside any procedure. Then, to invoke Form2 from within Form1, execute the following statement:

frm.Show();

This statement will bring up Form2 and usually appears in a button’s or menu item’s Click event handler. At this point, the two forms don’t communicate with one another. However, they’re both on the desktop and you can switch between them. There’s no mechanism to move information from Form2 back to Form1

The Show method opens Form2 in a modeless manner. The two forms are equal in stature on the desktop, and the user can switch between them. You can also display the second form in a modal manner, which means that users won’t be able to return to the form from which they invoked it.

Controlling One Form from within Another

Loading and displaying a form from within another form’s code is fairly small. In some situations, this is all the interaction you need between forms. Each form is designed to operate independently of the others, but they can communicate via public variables.

In most situations, however, you need to control one form from within another’s code. Controlling the form means accessing its controls and setting or reading values from within another form’s code.

 

Designing Menus

Menus are one of the most common and characteristic elements of the Windows user interface. Even in the old days of character-based displays, menus were used to display methodically organized choices and guide the user through an application. Despite the visually rich interfaces of Windows applications and the many alternatives, menus are still the most popular means of organizing a large number of options. Many applications duplicate some or all of their menus in the form of toolbar icons, but the menu is a standard fixture of a form. You can turn the toolbars on and off, but not the menus.

The Menu Editor

Menus can be attached only to forms, and they’re implemented through the MainMenu control. The items that make up the menu are MenuItem objects. The MainMenu control and MenuItem objects give you absolute control over the structure and appearance of the menus of your application.

The IDE provides a visual tool for designing menus, and then you can program their Click event handlers. In principle, that’s all there is to a menu: you design it, then you program each command’s actions. Depending on the needs of your application, you may wish to enable and disable certain commands, add context menus to some of the controls on your form, and so on. Because each item (command) in a menu is represented by a MenuItem object, you can control the application’s menus from within your code by manipulating the properties of the MenuItem objects.

Let’s start by designing a simple menu :

Ø  Double-click the MenuStrip icon on the Toolbox.

Ø  The MenuStrip control will be added to the form.

Ø  A single menu command will appear on your form.

Ø  Its caption will be Type Here.

If you don’t see the first menu item on the Form right away, select the MenuStrip control in the Components tray below the form. Do as the caption says.

Click it and enter the first command’s caption, File. As soon as you start typing, two more captions appear: one on the same level (the second command of the form’s main menu, representing the second pull-down menu) and another one below File (representing the first command on the File menu). Select the item under File and enter the string New.

Enter the remaining items of the File menu—Open, Save, and Exit—and then click somewhere on the form. All the temporary items (the ones with the Type Here caption) will disappear, and the menu will be finalized on the form. At any point, you can add more items by right-clicking one of the existing menu items and selecting Insert New.

To add the Edit menu, select the MenuStrip icon to activate the visual menu editor and then click the File item. In the new item that appears next to that, enter the string Edit. Press Enter and you’ll switch to the first item of the Edit menu. Fill the Edit menu with the commands.

Each menu item has a name, which allows you to access the properties of the menu item from within your code. The same name is also used in naming the Click event handler of the item. The default names of the menu items you add visually to the application’s menu are MenuItem1, MenuItem2, and so on. To change the default names to something more meaningful, you can change the Name property in the Properties window. To view the properties of a menu item, select it with the left mouse button, then right click it and select Properties from the context menu.

To create a separator bar in a menu, right-click the item you want to display below the separator and select Insert Separator. Separator bars divide menu items into logical groups, and even though they have the structure of regular menu commands, they don’t react to the mouse click. You can also create a separator bar by setting the item’s caption to a dash (-).

As you will notice, the menus expand by default to the bottom and to the right. To insert a menu command to the left of an existing command, or to insert a menu item above an existing menu item, right-click the item following the one you want to insert and select Insert New.

Programming Menu Commands

Menu commands are similar to controls. They have certain properties that you can manipulate from within your code, and they trigger a Click event when they’re clicked with the mouse or selected with the Enter key. If you double-click a menu command at design time, C# opens the code for the Click event in the code window. The name of the event handler for the Click event is composed of the command’s name followed by an underscore character and the event’s name, as with all other controls.

To program a menu item, insert the appropriate code in the MenuItem’s Click event handler. A related event is the Select event, which is fired when the cursor is placed over a menu item, even if it’s not clicked.

The New command’s code would be something like:

private void newToolStripMenuItem_Click(object sender, EventArgs e)

{

}

All you really need to know is that each menu item is a MenuItem object, and it fires the Click event every time it’s selected with the mouse or the keyboard. In most cases, you can treat the Click event handler of a MenuItem object just like the Click event handler of a Button.

Using Access and Shortcut Keys

Menus are a convenient way of displaying a large number of choices to the user. They allow you to organize commands in groups, according to their function, and are available at all times. Opening menus and selecting commands with the mouse, however, can be an inconvenience. When using a word processor, for example, you don’t want to have to take your hands off the keyboard and reach for the mouse. To simplify menu access, C# supports shortcut keys.

Shortcut Keys

Shortcut keys are similar to access keys, but instead of opening a menu, they run a command when pressed. Assign shortcut keys to frequently used menu commands, so that users can reach them with a single keystroke. Shortcut keys are combinations of the Ctrl key and a function or character key.

For example, the usual access key for the Close command (once the File menu is opened with Alt+F) is C; but the usual shortcut key for the Close command is Ctrl+W. 

To assign a shortcut key to a menu command, drop down the Shortcut list in the MenuItem’s Properties window and select a keystroke. You don’t have to insert any special characters in the command’s caption, nor do you have to enter the keystroke next to the caption. To view the possible keystrokes you can use as shortcuts, select a MenuItem in the Form Designer and expand the drop-down list of the Shortcut property in the Properties window. When assigning access and shortcut keys, take into consideration well-established Windows standards.

MDI Applications: MDI applications must have at least two forms, the parent form and one or more child forms. There may be many child forms contained within the parent form, but there can be only one parent form. The parent form is the MDI form, or MDI container, because it contains all child forms. The parent form may not contain any controls expect MinuStrip, ToolStrip and StatusStrip comtrol.

Creating an MDI form is a simple, only you have to set one property of a from to true.

Ex: IsMdiContainer = True

The form whose IsMdiContainer property is set to True, the said form is called as MDI Container / MDI Parent form.

 

To Create MDI Child form, following line of code is used.

private void newToolStripMenuItem_Click(object sender, EventArgs e)

 {

    Form2 f = new Form2();

    f.MdiParent = this;

    f.Show();

 }

 In above peace of code,

1)      Form2 f = new Form2(); is used to create an instance of new form.

2)      f.MdiParent = this; statement is used to assign the current working form as MdiParent using keyword this.

3)      f.Show(); is used to show the MdiChild form.

 

Thursday, April 16, 2020

ASP.Net (Query String, Cookies and Working with Database)

Query String

The most common approach to pass information to server is by using a query string in the URL. This approach is mostly found in search engines. For example, if you perform a search on the Google website, you’ll be redirected to a new URL that make use of your search parameters. For example:

http://www.google.com/search?q=shahu+college

The query string is the portion of the URL after the question mark. In example above, it defines a single variable named q, which contains the string shahu+college.

The advantage of the query string is that it’s lightweight and doesn’t apply any kind of burden on the server.
However, it has limitation also:

Information is limited to simple strings, which must contain URL-legal characters.

Information is clearly visible to the user and to anyone else who cares to eavesdrop on the Internet.

Many browsers impose a limit on the length of a URL (usually from 1 KB to 2 KB), you can’t place a large amount of information in the query string and still be assured of compatibility with most browsers.

The Response.Redirect() methodis used to build query string:

Response.Redirect("newpage.aspx?recordID=10");

You can send multiple parameters separated with an ampersand (&):

Response.Redirect("newpage.aspx?recordID=10&class=BCATY");

The receiving page has an easier time working with the query string. It can receive the values from the QueryString dictionary collection exposed by the built-in Request object:

string ID = Request.QueryString["recordID"];
classname = Request.QueryString["class"];

Cookies

Cookies provide a way to store information for later use. Cookies are small files that are created in the web browser’s memory (if they’re temporary) or on the client’s hard drive (if they’re permanent). One advantage of cookies is that they work transparently, without the user being aware that information needs to be stored.
As cookies are stored on the user’s computer as plaintext, you should never use them to store any sensitive data, such as a password.
The following line of code is used to create cookies:

HttpCookie myCookie = new HttpCookie("CookieName");
myCookie.Expires = DateTime.Now.AddMonths(3);
myCookie.Value = "My Cookie";
Response.Cookies.Add(myCookie);

To read cookie the line of code can be implemented as

HttpCookie myCookie = Request.Cookies.Get("CookieName");
if (myCookie != null)
{
Label1.Text = myCookie.Value; // would display "Cookie value"
}




Database Connectivity:

Inserting a record in the table:

Design of Application:


Programme code for the design:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <h1>Student Information</h1><br />
    Student P.R.No : <asp:TextBox ID=txtprno runat="server"></asp:TextBox><br />
    Student Name : <asp:TextBox ID=txtsname runat="server"></asp:TextBox><br />
    contact No : <asp:TextBox ID = txtcno runat="server"></asp:TextBox><br />
    <asp:Button ID="btnSave" Text="Save" runat="server" onclick="btnSave_Click" />
    <asp:Button ID="btnClear" Text="Clear" runat="server" />

        <br />
        <asp:Label ID="Label1" runat="server" Text=""></asp:Label>
    </div>
    </form>
</body>
</html>

C# code for database connectivity:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OleDb;
using System.Data;

public partial class _Default : System.Web.UI.Page
{
    OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=E:\DataBaseDemo\student.accdb");
    OleDbCommand cmd;
    protected void Page_Load(object sender, EventArgs e)
    {
        con.Open();
      
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
         string s;
         s = "insert into studdtl values(" + txtprno.Text + ",'" + txtsname.Text + "'," + txtcno.Text + ")";
         cmd = new OleDbCommand();
         cmd.Connection = con;
         cmd.CommandText = s;
         cmd.ExecuteNonQuery();
         Label1.Text = "Record Saved..." + txtprno.Text;
     }
 }

Saturday, April 4, 2020

Introduction to C++ and OOPS



Object oriented concepts:
Object-Oriented Programming or OOPs refers to languages that uses objects in programming. Object-oriented programming aims to implement real-world entities like inheritance, hiding, polymorphism etc in programming.
The main aim of OOP is to bind together the data and the functions that operate on them so that no other part of the code can access this data except that function.

Principles (Features) of Object Oriented Programming:
1. Encapsulation
2. Data abstraction
3. Polymorphism
4. Inheritance
5. Dynamic binding
6. Message passing

Encapsulation: Wrapping of data and functions together as a single unit is known as encapsulation. By default data is not accessible to outside world and they are only accessible through the functions which are wrapped in a class. Prevention of data direct access by the program is called data hiding or information hiding

Data abstraction: Abstraction refers to the act of representing essential features without including the back ground details or explanation. Classes use the concept of abstraction and are defined as a list of attributes such as size, weight, cost and functions to operate on these attributes. They encapsulate all essential properties of the object that are to be created. The attributes are called as data members as they hold data and the functions which operate on these data are called as member functions.
Class use the concept of data abstraction so they are called abstract data type (ADT).

Polymorphism: Polymorphism comes from the Greek words “poly” and “morphism”. “poly” means many and “morphism” means form i.e.. many forms. Polymorphism means the ability to take more than one form. For example, an operation have different behavior in different instances. The behavior depends upon the type of the data used in the operation.
Different ways to achieving polymorphism in C++ program are:
1) Function overloading 2) Operator overloading

Inheritance: Inheritance is the process by which one object can acquire the properties of another. Inheritance is the most promising concept of OOP, which helps realize the goal of constructing software from reusable parts, rather than hand coding every system from scratch. Inheritance not only supports reuse across systems, but also directly facilitates extensibility within a system. Inheritance coupled with polymorphism and dynamic binding minimizes the amount of existing code to be modified while enhancing a system.
When the class child, inherits the class parent, the class child is referred to as derived class (sub class) and the class parent as a base class (super class). In this case, the class child has two parts: a derived part and an incremental part. The derived part is inherited from the class parent. The incremental part is the new code written specifically for the class child.

Dynamic binding: Binding refers to linking of procedure call to the code to be executed in response to the call. Dynamic binding(or late binding) means the code associated with a given procedure call in not known until the time of call at run time.

Message passing: An object oriented program consists of set of object that communicate with each other. Objects communicates with each other by sending and receiving information. A message for an object is a request for execution of a procedure and therefore invoke the function that is called for an object and generates result.


Advantages and Applications of OOPS

Advantages (Benefits) of Object Oriented Programming (OOPs)
Reusability: In OOPs programs functions and modules that are written by a user can be reused by other users without any modification.
Inheritance: Through this we can eliminate redundant code and extend the use of existing classes.
Data Hiding: The programmer can hide the data and functions in a class from other classes. It helps the programmer to build the secure programs.
Reduced complexity of a problem: The given problem can be viewed as a collection of different objects. Each object is responsible for a specific task. The problem is solved by interfacing the objects. This technique reduces the complexity of the program design.
Easy to Maintain and Upgrade: OOP makes it easy to maintain and modify existing code as new objects can be created with small differences to existing ones. Software complexity can be easily managed.
Message Passing: The technique of message communication between objects makes the interface with external systems easier.
Modifiability: it is easy to make minor changes in the data representation or the procedures in an Object Oriented program. Changes inside a class do not affect any other part of a program, since the only public interface that the external world has to a class is through the use of methods.

Applications of OOP:
Real-time systems
Simulation and modeling
Object-oriented databases
Hypertext, hypermedia and expertext
AI and expert systems
Neural networks and parallel programming
Decision support and office automation systems
CIM/CAM/CAD systems.

Applications of C++
C++ is a versatile language for handling very large programs. It is suitable for virtually any
programming task including development of editors, compilers, databases, communication systems and any complex real-life application systems.
Since C++ allows us to create hierarchy-related objects, we can build special object oriented libraries which can be used later by many programmers.
While C++ is able to map the real-world problem properly, the C part of C++ gives the language the ability to get close to the machine-level details.
C++ programs are easily maintainable and expandable. When a new feature needs to be implemented, it is very easy to add to the existing structure of an object.

Data types, new operators and keywords, type conversion in C++

Data Types:
The language C++ supports all the data types available in ‘C’ language. The data types of language C++ can be viewed as given bellow.
 
Data Types
 As shown in above figure,

The user-define data type Structure and union are same as that of the implementation in C, there is small advantage in implementation of structure in C++, that we will discuss later. The new data type which is not in C is the “class”. The concept of the class is the main concept in C++ programming.
The Library / Built-In data type consist of all the data types as that of the data types used in C, the range and keyword used for these data type is similar to C. There is little bit difference in size used in C and in C++.
The derived data types, array, function. Pointer are also similar to the language used in C. The language C++ introduces new data type as “reference”

Operators and Keywords:

C++ has a rich set of operators. All operators in C are used as it is with their meaning in C++ also.
The various operators are:-
a. Assignment Operator
b. Arithmetic Operator
c. Relational Operator
d. Logical Operator
d. Bit wise Operator
e. Increment/Decrement operator
f. Shortcut Operator
g. Conditional Operator
h. Special operator

Assignment operator:
The assignment operator is used to store the values of constants, variables, and result of an expression and return value of a function into variable placed in left side.
Operator Symbol: =
                Ex :        1) a = 6;               2) a = b;                               3) a = b+c;

Arithmetic operators:
The arithmetic operators are used to perform the basic operations like addition, subtraction,
multiplication, division and modulus.
The operators are: Addition (+) , subtraction () , multiplication (*) , Division ( / ), modulus division (%)

Ex:
1) x=a+b;     2) x=a-b;            3) x=a*b;           4) x=a/b;           5) x=a%b;

Increment/Decrement operators:
The Increment operators ++ increase the value of variable by one.
The Decrement operators -- decrease the value of variable by one.
 Ex :
                i++,
                ++i,
                i--,
                --i.

Shortcut operators:
When the arithmetic operation on value of a variable is to be performed and assigned to the same variable, we can use shortcut assignment operator.
The operators are: +=, – =, *=, /=, %=

Ex:
                A += 2;                                A -= 3;
                A *= 2;                                 A /= 2;
                A %= 4;

Sizeof:
The sizeof operator is used to find the size of the memory occupied by an variable in terms of bytes.
Ex : a = sizeof(int);

Relational operators:
The operators that do relationship tests with the operands are called relational operators.
The relational operators are:
< (is less than)                                 
<= (is less than or equal to)           
> (is greater than)                           
>= (is greater than or equal to)    
== (is equal to)                                
!= (is not equal to)                          

Logical operators:
Logical operators are used when more than one relationship should be considered in evaluation.
It gives either True value or False value.
The operators are
            AND operator: &&               
            OR operator: ||                     
            NOT operator: !                    

The language C++ introduces some new operators which are:

1) << :-                       insertion operator (or output operator)
2) >> :-                       extraction operator (or input operator)
3) :: :-                          Scope resolution operator
4) ::* :-                        pointer-to-member declarator
5) ->*                          pointer-to-member operator
6) .*                             pointer-to-member operator
7) endl                       line feed operator
8) new                       memory allocation operator

Keywords:
The keywords are the reserved words with specific meaning, these cannot be used and programe names or variable names in programe or user define program name.
Some of the keywords are:
            auto                break              case                 catch               char                class                        const               continue         default            delete              do                    double            
            else                 enum             extern                         float                for                   friend
            goto                if                      inline               int                    long                 new
            operator         private            protected       public              register           return
            short               signed             sizeof              static               struct              switch  
            template         this                  throw              try                   typedef           union
            unsigned        virtual             void                 volatile            while

Mostly used new keywords in C++ are new, class, inline, private, protected, public, virtual, etc. These keywords plays very important role in C++ programming.

The simple programe in C++ can be written as

#include<iostream.h>
#include<conio.h>
void main()
{
   int a,b,c;
   clrscr();
   cout<<"Enter first number ";
   cin>>a;
   cout<<"Enter second number ";
   cin>>b;
   c = a + b;
   cout<<"Addition is "<<c;
   getch();
}

In the programe above

iostream.h:- is an header file containing the information about input and output stream. i.e. input and output statements used in C++.

Input statement:- The “cin” is the statement used to read the values from keyboard. The general syntax of cin statement is given as follows:
            Syntax:
                         cin>>variable_name[>>var_name>>var_name…..];
here cin is the statement used to read values from keyboard. The operator >> is known as Extraction or “get from” operator. It extracts (or takes) the value form the keyboard and assign it to the variable.
            int a,b,c;
                        cin>>a;
                        cin>>b>>c;

Output statement:- The “cout” is the statement used to display values on to the monitor. The general syntax of cout statement is given as follows:
            Syntax:
                         1) cout<<variable_name[<<var_name<<var_name…..];
                         2) cout<<”Any data in double quot..”[<<”…….”<<”var_name”<<…..];
                        3) cout<<“string information”<<variable_name;

here cout is the statement used to display values on monitor. The operator << is known as Insertion or “put to” operator. It inserts (or sends) the value of variable to the monitor.
            int a,b;
            a = 90; b = 20;
            cout<<a;
            cout<<a<<b;
            cout<<”The value of A = “<<a<<” B = “<<b;
            cout<<”The addition is “<<a+b;

Classes & Objects
Class:
A Class is an user define data type that can be treated like any other built-in data type. The class is a way to bind data and its associated functions together. The class allows the data and functions to be hidden form external user i.e. form user, if necessary. When we are defining a class it means we are creating new user define data type also known as abstract data type.

General form of a class declaration is:
class class_name
{
private:
variable declarations;
function declarations;
public:
variable declarations;
function declarations;
};

In above declaration
Class is a keyword used to declare class.
Private, public are the two visibility modes, these are also called as access specifiers.  These are used to decide whether to allow user to make use of variables and or functions. The public access specifier is allows user to make use of variables / functions, whereas private access specifier is used to protect variables / functions.

The variables declared under public / private / protected access specifier are known as data members / properties of class. The functions declared in class are called as method members of class. The method members are used to make operations on data members of class.

Object:
Objects are the basic run-time entities in an object-oriented system. They may represent a person, a place, a bank account, a table of data or any item the program has to handle. They may be represents user-defined data such as vectors, time and lists.
To make use of the data members and method members of class one has to create and instance / variable of a class. The class instance / variable is called as an object of that class. The object of a class contains all the properties and methods of a class. It is also termed as blue print of a class.
The general syntax of creating object is
                        class_name variable_name;

Example of creating class and object:

#include<iostream.h>
#include<conio.h>
class student
{
   private:
            int rollno;                               // Data Member
            char sname[20];                    // Data Member
   public:
            void getdata()                        // Method Member
            {
               cout<<"Enter roll Number ";
               cin>>rollno;
               cout<<"Enter name of Student ";
               cin>>sname;
            }
            void putdata()                       // Method Member
            {
              cout<<" The Roll Number is "<<rollno;
              cout<<" \n The Name is "<<sname;
            }
};
void main()
{
   student obj;                         // Creating an object of class
   clrscr();
   obj.getdata();          // accessing members of class using object
   obj.putdata();          // accessing members of class using object
   getch();
}

The operator dot ( . ) is used to access class members using object of the class.