0% found this document useful (0 votes)
2K views

Research Paper

This research paper summarizes an overview of the C++ programming language. It discusses the design and evolution of C++, presenting the key concepts using examples. C++ supports efficient low-level computation, data abstraction, object-oriented programming, and generic programming. The paper is organized around the main programming styles directly supported by C++, including the C programming model, C++ abstraction mechanisms, large-scale programming, and the C++ standard library.

Uploaded by

Tayyab
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2K views

Research Paper

This research paper summarizes an overview of the C++ programming language. It discusses the design and evolution of C++, presenting the key concepts using examples. C++ supports efficient low-level computation, data abstraction, object-oriented programming, and generic programming. The paper is organized around the main programming styles directly supported by C++, including the C programming model, C++ abstraction mechanisms, large-scale programming, and the C++ standard library.

Uploaded by

Tayyab
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

RESEARCH PAPER

TOPIC: C++ PROGRAMMING


SUBJECT: RESEARCH
METHODOLOGY
SUBMITTED BY: TAYYAB ZAMAN
ROLL NO: 02
SUBMITTED TO: DR FAHEEM
BCS-S0FTWARE
SEMESTER: 8th
BATCH: 2nd
An Overview of the C++
Programming Language

ABSTRACT
This overview of C++ presents the key design, programming, and language-technical concepts
using examples to give the reader a feel for the language. C++ is a general-purpose
programming language with a bias towards systems programming that supports efficient low-
level computation, data abstraction, object-oriented programming, and generic programming.

Introduction and Overview


The C++programming language provides a model of memory and computation that closely
matches that of most computers. In addition, it provides powerful and flexible mechanisms for
abstraction; that is, language constructs that allow the programmer to introduce and use new
types of objects that match the concepts of an application. Thus, C++ supports styles of
programming that rely on fairly direct manipulation of hardware resources to deliver a high
degree of efficiency plus higher-level styles of programming that rely on user-defined types to
provide a model of data and computation that is closer to a human’s view of the task being
performed by a computer. These higher-level styles of programming are often called data
abstraction, object-oriented programming, and generic programming.

This paper is organized around the main programming styles directly supported by C++:

 The Design and Evolution of C++ describes the aims of C++ and the principles that
guided its evolution.
 The C Programming Model presents the C subset of C++and other C++facilities
supporting traditional systems-programming styles.
 The C++ Abstraction Mechanisms introduces C ++ ’s class concept and its use for
defining new types that can be used exactly as built-in types, shows how abstract classes
can be used to provide inter-faces to objects of a variety of types, describes the use of
class hierarchies in object-oriented programming, and presents templates in support of
generic programming.
 Large-Scale Programming describes namespaces and exception handling provided to ease
the composition of programs out of separate parts.
 The C++Standard Library presents standard facilities such as I/O streams, strings,
containers (e.g. Vector, list and map), generic algorithms (e.g. s sort(), find(), for_
each()) and support for numeric computation.

To round off, a brief overview of some of the tasks that C++has been used for and some
suggestions for further reading are given

The Design and Evolution of C++


C++ was designed and implemented by Bjarne Stroustrup (the author of this article) at AT&T
Bell Laboratories to combine the organizational and design strengths of Simula with C’s
facilities for systems programming. The initial version of C++, called ‘‘C with Classes’’
[Stroustrup,1980], was first used in 1980; it supported traditional system programming
techniques and data abstraction. The basic facilities for object-oriented programming were
added in 1983 and object-oriented design and programming techniques were gradually
introduced into the C++ community. The language was first made commercially available in
1985 [Stroustrup,1986] [Stroustrup,1986b]. Facilities for generic programming were added to
the language in the 1987-1989 time frame [Ellis,1990] [Stroustrup,1991]. As the result of
widespread use and the appearance of several independently-developed C++ implementations,
formal standardization of C++ started in 1990 under the auspices of the American
National Standards Institute, ANSI, and later the International Standards Organization, ISO,
leading to an international standard in 1998 [C++,1998]. During the period of standardization
the standards committee acted as an important focus for the C++
community and its draft standards acted as interim definitions of the language. As an active
member of the standards committee, I was a key participant in the further evolution of C++.
Standard C++is a better approximation to my ideals for C++ than were earlier versions. The
design and evolution of C++ is documented in [Stroustrup,1994] [Stroustrup,1996] and
[Stroustrup,1997b]. The language as it is defined at the end of the standardization process and
the key design and programming techniques it directly supports are presented in
[Stroustrup,1997].

The C Programming Model


A fundamental property of computers in widespread use has remained remarkably constant:
Memory is a sequence of words or bytes, indexed by integers called addresses. Modern
machines – say, designed during the last 20 years – have in addition tended to support directly
the notion of a function call stack. Furthermore, all popular machines have some important
facilities – such as input-output – that do not fit well into the conventional byte- or word-oriented
model of memory or computation. These facilities may require
special machine instructions or access to ‘‘memory’’ locations with peculiar semantics. Either
way, from a higher-level language point of view, the use of these facilities is messy and
machine-architecture-specific. C is by far the most successful language providing the
programmer with a programming model that closely matches the machine model. C provides
language-level and machine-architecture-independent notions that directly map to the key
hardware notions: characters for using bytes, integers for using words,
pointers for using the addressing mechanisms, functions for program abstraction, and an absence
of con-straining language features so that the programmer can manipulate the inevitable messy
hardware-specific details. The net effect has been that C is relatively easy to learn and use in
areas where some knowledge of the real machine is a benefit. Moreover, C is easy enough to
implement that it has become almost universally available.
Arrays and Pointers
A C array is simply a sequence of memory locations. For example:

int v[10] ; / / an array of 10 ints


v [3 ] = 1 ; / / assign 1 to v[3]
int x = v [3] ; / / read from v[3]

The subscript notation [] is used both in declarations to indicate an array and in expressions
referring to elements of an array.
A C pointer is a variable that can hold an address of a memory location. For example:

int* p; / / p is a pointer to an int


p = &v[7] ; / / assign the address of v[7] to p
*p=4; / / write to v[7] through p
Int y = *p; / / read from v[7] through p

The pointer dereference (‘‘points to’’) notation * is used both in declarations to indicate a pointer
and in expressions referring to the element pointed to. adopted this inherently simple and close-
to-the-machine notion of memory from C. It also adopted C’s notion of expressions, control
structures, and functions. For example, we can write a function that finds an element in a vector
and returns a pointer to the matching element like this:

int* find (int v[] , int vsize , int Val) / / find Val in v
{
for (int i = 0 ; i<vsize; i++) / / loop through 0..vsize-1
if (v [i]==Val) return &v [i] ; / / if Val is found return pointer to element
return &v [vsize] ; / / if not found return pointer to one-beyond-the-end of v
}
The ++ operator means increment. Thus, the name C++ can be read as ‘‘one more than C,’’
‘‘next C,’’ or ‘‘successor to C.’’ It is pronounced ‘‘See Plus Plus.’’ The find() function might be
used like this:
Int count[ ] = { 2, 3, 1, 9, 7, 3, 3, 0, 2 };
Int count _size= 9;
void f ( )
{
int* p= find (count, count_size,7) ; / / find 7 in count
int* q= find (count, count_size,0) ; / / find 0 in count
*q = 4;
}

The C++ standard library provides more general versions of functions such as find( );
A function declared void, as f ( ) above doesn’t return a value.

Abstraction
In addition to convenient and efficient mechanisms for expressing computation and allocating
objects, we need facilities to manage the complexity of our programs. That is, we need language
mechanisms for creating types that are more appropriate to the way we think (to our application
domains) than are the low-level built-in features.

Object-Oriented Programming
Object-oriented programming is a set of techniques that rely on hierarchies of classes to provide
extensibility and flexibility. The basic language facilities used are the user-defined types
themselves, the ability to derive a class from another, and virtual functions. These features allow
a programmer to rely on an interface (a class, often an abstract class) without knowing how its
operations are implemented. Conversely, they allow new classes to be built directly on older
ones without disturbing users of those older classes. As an example, consider the simple task of
getting an integer value from a user to an application
through some user-interface system. Assuming that we would like to keep the application
independent of the details of the user-interface system we could represent the notion of an
interaction needed to get an integer as a class IVal _box:

class IVal _box


{
public:
virtual int get _value( ) = 0; / / get value back to application
virtual void prompt( ) = 0; / / prompt the user
};

Naturally, there will be a variety of IVal_ boxes:


class Ival__dial : public Ival _box { /* ... */ };
class Ival _slider : public Ival _box { /* ... */ };

Generic Programming
Given classes and class hierarchies, we can elegantly and efficiently represent individual
concepts and also represent concepts that relate to each other in a hierarchical manner. However,
some common and important concepts are neither independent of each other nor hierarchically
organized. For example, the notions ‘‘vector of integer’’ and ‘‘vector of complex number’’ are
related through the common concept of a vector and differ in the type of the vector elements
(only). Such abstractions are best represented through parameterization. For example, the vector
should be parameterized by the element type. C++ provides parameterization by type through the
notion of a template. It was a crucial design criterion that templates should be flexible and
efficient enough to be used to define fundamental containers with severe efficiently constraints.
In particular, the aim was to be able to provide a vector template class that did not impose run-
time or space overheads compared to a built-in array.

The C++ Standard Library


The standard library provides:
 Basic run-time language support (e.g., for allocation and run-time type information).
 The C standard library (with very minor modifications to minimize violations of the type
system).
 Strings and I/O streams (with support for international character sets and localization)
 A framework of containers (such as vector, list, and map) and algorithms using
containers (such as general traversals, sorts, and merges).
 Support for numerical computation (complex numbers plus vectors with arithmetic
operations,
BLAS-like and generalized slices, and semantics designed to ease optimization).
The main criterion for including a class in the library was that it would somehow be used by
almost every C++ programmer (both novices and experts), that it could be provided in a general
form that did not add significant overhead compared to a simpler version of the same facility,
and that simple uses should be easy to learn. Essentially, the C++ standard library provides the
most common fundamental data structures together with the fundamental algorithms used on
them. The framework of containers, algorithms, and iterators is commonly referred to as the
STL. It is primarily the work of Alexander Stepanov [Stepanov,1994].

References

[Barton,1994] John J. Barton and Lee R. Nackman: Scientific and Engineering C++. Addison-
Wesley. Reading, Mass. 1994. ISBN 1-201-53393-6.

[Berg,1995] William Berg, Marshall Cline, and Mike Girou: Lessons Learned from the OS/400
OO Project. CACM. Vol. 38 No. 10. October 1995.

[Birtwistle,1979] Graham Birtwistle, Ole-Johan Dahl, Bj rn Myrhaug, and Kristen Nygaard:


SIMULA BEGIN. Studentlitteratur, Lund, Sweden. 1979. ISBN 91-44-06212-5.
[Booch,1994] Grady Booch: Object-Oriented Analysis and Design. Benjamin/Cummings. Menlo
Park, California. 1994. ISBN 0-8053-5340-2.

[Budge,1992] Kent Budge, J. S. Perry, and A. C. Robinson: High-Performance Scientific


Computation using C++. Proc. USENIX C++Conference. Portland, Oregon. August 1992.

[C,1990] X3 Secretariat: Standard – The C Language. X3J11/90-013. ISO Standard ISO/IEC


9899. Computer and Business Equipment Manufacturers Association. Washington,
DC, USA.[C++ 1998] X3 Secretariat: Standard – The C++ Language. ISO/IEC:98-14882.
Information Technology Council (NSITC). Washington, DC, USA.

[Stepanov,1994] Alexander Stepanov and Meng Lee: The Standard Template Library. HP Labs
Technical Report HPL-94-34 (R. 1). August, 1994

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy