Saturday, August 18, 2018

c++ introduction and some concept

c++

c++ is a general-purpose programming language. It has imperativeobject-oriented and genericprogramming features, while also providing facilities for low-level memory manipulation.It was designed with a bias toward system programming and embedded, resource-constrained and large systems, with performance, efficiency and flexibility of use as its design highlights.

ISO C++ Logo.svg
ParadigmMulti-paradigmproceduralfunctionalobject-orientedgeneric[1]
Designed byBjarne Stroustrup
First appeared1985; 33 years ago
Stable release
ISO/IEC 14882:2017 / 1 December 2017; 8 months ago
Typing disciplineStaticnominativepartially inferred
Implementation languageC++ or C
Filename extensions.C .cc .cpp .cxx .c++ .h .hh .hpp .hxx .h++

Language

The C++ language has two main components: a direct mapping of hardware features provided primarily by the C subset, and zero-overhead abstractions based on those mappings. Stroustrup describes C++ as "a light-weight abstraction programming language [designed] for building and using efficient and elegant abstractions";[6] and "offering both hardware access and abstraction is the basis of C++. Doing it efficiently is what distinguishes it from other languages".[39]
C++ inherits most of C's syntax. The following is Bjarne Stroustrup's version of the Hello world program that uses the C++ Standard Library stream facility to write a message to standard output:[40][41]
1 #include <iostream>
2 
3 int main()
4 {
5     std::cout << "Hello, world!\n";
6 }

Object

C++ introduces object-oriented programming (OOP) features to C. It offers classes, which provide the four features commonly present in OOP (and some non-OOP) languages: abstractionencapsulationinheritance, and polymorphism. One distinguishing feature of C++ classes compared to classes in other programming languages is support for deterministic destructors, which in turn provide support for the Resource Acquisition is Initialization (RAII) concept.


class

Class: The building block of C++ that leads to Object Oriented programming is a Class. It is a user defined data type, which holds its own data members and member functions, which can be accessed and used by creating an instance of that class. 
  • A Class is a user defined data-type which has data members and member functions.
  • Data members are the data variables and member functions are the functions used to manipulate these variables and together these data members and member functions defines the properties and behavior of the objects in a Class.
  • In the above example of class Car, the data member will be speed limitmileage etc and member functions can be apply brakesincrease speed etc.
Inheritance

Inheritance allows one data type to acquire properties of other data types. Inheritance from a base class may be declared as public, protected, or private. This access specifier determines whether unrelated and derived classes can access the inherited public and protected members of the base class. Only public inheritance corresponds to what is usually meant by "inheritance".

Operator overloading


Operators that cannot be overloaded
OperatorSymbol
Scope resolution operator::
Conditional operator?:
dot operator.
Member selection operator.*
"sizeof" operatorsizeof
"typeid" operatortypeid
C++ provides more than 35 operators, covering basic arithmetic, bit manipulation, indirection, comparisons, logical operations and others. Almost all operators can be overloaded for user-defined types, with a few notable exceptions such as member access (. and .*) as well as the conditional operator. The rich set of overloadable operators is central to making user-defined types in C++ seem like built-in types.

polymorphism
Polymorphism enables one common interface for many implementations, and for objects to act differently under different circumstances.
C++ supports several kinds of static (resolved at compile-time) and dynamic (resolved at run-timepolymorphisms, supported by the language features described above. Compile-time polymorphism does not allow for certain run-time decisions, while runtime polymorphism typically incurs a performance penalty.

see also


No comments:

Post a Comment

Top 50 Python proggraming examples with logic

Python Programming Examples The best way to learn any programming language is by practicing examples on your own. You are advised ...