1. Make your C++ class Final/Sealed ( Class that
can not be inherited )
You all knows that final class is inbuilt in
java. But in C++ you have to create final class. The trick is to declare
destructor as private.
Class Final
{
Public:
Static Final CreateInstance() { ; }
Private:
~Final() { ; }
};
Class DependentClass : Final
{
...
};
Now Error will appear during compilation. Child
class can'nt inherit final class.. Because destructor of final class is
private.
We can always declare private as constructor of
them. But constructor can be overloaded but Destructor can'nt be Overloaded. So
to be safe , define Destructor as private rather defining it's constructor.
2. Methods not inherited in C++
C++ inheritance is very similar to a parent-childrelationship. When a class is inherited all the functions and data member are inherited, although not all of them will be accessible by the member functions of the derived class. But there are some exceptions to it too. Some of the exceptions to be noted in C++ inheritance are as follows.
1. The constructor of a base class are not inherited
2. The destructor of a base class are not inherited
3. The assignment operator is not inherited
4. Friend functions and friend classes of the base class are also not inherited.
There are some points to be remembered about C++ inheritance. The protected and public variables or members of the base class are all accessible in the derived class. But a private member variable not accessible by a derived class.
3. Private Inheritance:
C++ inheritance is very similar to a parent-childrelationship. When a class is inherited all the functions and data member are inherited, although not all of them will be accessible by the member functions of the derived class. But there are some exceptions to it too. Some of the exceptions to be noted in C++ inheritance are as follows.
1. The constructor of a base class are not inherited
2. The destructor of a base class are not inherited
3. The assignment operator is not inherited
4. Friend functions and friend classes of the base class are also not inherited.
There are some points to be remembered about C++ inheritance. The protected and public variables or members of the base class are all accessible in the derived class. But a private member variable not accessible by a derived class.
3. Private Inheritance:
Private inheritance does not model an is-a
relationship in the same way that public inheritance does. Instead, private
inheritance refers to the idea of being "implemented in terms of a".
The key difference is that whereas public inheritence provides a common interface between two classes, private inheritance does not--rather, it makes all of the public functions of the parent class private in the child class. This means that they can be used in order to implement the child class without being accessible to the outside world.
The syntax for private inheritance is almost exactly the same as for public inheritance.
class obj : private implementationDetailOfObj.
The key difference is that whereas public inheritence provides a common interface between two classes, private inheritance does not--rather, it makes all of the public functions of the parent class private in the child class. This means that they can be used in order to implement the child class without being accessible to the outside world.
The syntax for private inheritance is almost exactly the same as for public inheritance.
class obj : private implementationDetailOfObj.
4. UTF-8 & C++
A simple, portable and lightweight generic
library for handling UTF-8 encoded strings.
Strcoll
The C++ strcoll function compares two strings according to the LC_COLLATE category, which provides specific collating information. This function may fail if either string contains characters outside the domain of the current collating sequence. It is multi-thread safe as long no other thread calls setlocale() while this function is executing. The following steps will help you use the strcoll function in C++.
iconv
The iconv API is the standard programming interface for converting character stringsfrom one character encoding to another in Unix-like operating systems. Initially appearing on the HP-UX operating system, it was standardized within XPG4 and is part of the Single UNIX Specification (SUS).
All recent Linux distributions contain a free implementation of iconv() as part of the GNU C Librarywhich is the C library for current Linux systems. To use it, the GNU glibc localesneed to be installed, which is provided as a separate package, named glibc-locale usually, and is normally installed by default
Mbstowcs
The C++ strcoll function compares two strings according to the LC_COLLATE category, which provides specific collating information. This function may fail if either string contains characters outside the domain of the current collating sequence. It is multi-thread safe as long no other thread calls setlocale() while this function is executing. The following steps will help you use the strcoll function in C++.
iconv
The iconv API is the standard programming interface for converting character stringsfrom one character encoding to another in Unix-like operating systems. Initially appearing on the HP-UX operating system, it was standardized within XPG4 and is part of the Single UNIX Specification (SUS).
All recent Linux distributions contain a free implementation of iconv() as part of the GNU C Librarywhich is the C library for current Linux systems. To use it, the GNU glibc localesneed to be installed, which is provided as a separate package, named glibc-locale usually, and is normally installed by default
Mbstowcs
Convert multibyte string to wide-character
string.The C multibyte character string mbstris interpreted character by
character and translated to its wchar_t equivalent, which is stored in the
location pointed by wcstr. The length in characters of the resulting string,
not including the ending null-character, is returned.
Wcstombs
Wcstombs
Convert wide-character string to multibyte
string.The C wchar_t string wcstris interpreted character by character and
translated to its multibyte equivalent, which is stored in the location pointed
by mbstr. The length in bytes of the resulting multibyte string, not including
the ending null-character, is returned.
Mblen
Mblen
Get length of multibyte character. The size of
the multibyte character pointed by pmb is determined, examining at most max
bytes.mblen has its own internal shift state, which is altered as necessary
only by calls to this function.
Glib
For many applications, C with GLib is an alternative to C++ with STL (see GObject for a detailed comparison).
In computing, GLibrefers to a cross-platform software utility library. It started life as part of the GTK+project, however, before releasing version 2 of GTK+, the project's developers decided to separate non-GUI-specific code from the GTK+ platform, thus creating GLib as a separate product. GLib was released as a separate library so other developers, those that did not make use of the GUI-related portions of GTK+, could make use of the non-GUI portions of the library without the overhead of depending on a full-blown GUI library.
Since GLib is a cross-platform library, applications using it to interface with the operating system are usually portable across different operating systems without major changes.
ICU
The International Component for Unicode (ICU) is a mature, portable set of C/C++ and Java libraries for Unicode support, software internationalization (I18N) and globalization (G11N), giving applications the same results on all platforms.
Glib
For many applications, C with GLib is an alternative to C++ with STL (see GObject for a detailed comparison).
In computing, GLibrefers to a cross-platform software utility library. It started life as part of the GTK+project, however, before releasing version 2 of GTK+, the project's developers decided to separate non-GUI-specific code from the GTK+ platform, thus creating GLib as a separate product. GLib was released as a separate library so other developers, those that did not make use of the GUI-related portions of GTK+, could make use of the non-GUI portions of the library without the overhead of depending on a full-blown GUI library.
Since GLib is a cross-platform library, applications using it to interface with the operating system are usually portable across different operating systems without major changes.
ICU
The International Component for Unicode (ICU) is a mature, portable set of C/C++ and Java libraries for Unicode support, software internationalization (I18N) and globalization (G11N), giving applications the same results on all platforms.
C++ Versions => C++98, C++11, C++14, C++17
C++11 Features:
Threading Library
(concurrency):
C++11 has a thread
class that represents an execution thread, promises and futures, which
are objects that are used for synchronization in a concurrent environment,
the async() function template for launching concurrent tasks,
and the thread_local storage type for declaring thread-unique
data. For a quick tour of the C++11 threading library, read Anthony Williams’
Simpler Multithreading in C++0x.
New Smart Pointer
Classes:
C++98 defined only one
smart pointer class, auto_ptr, which is now deprecated. C++11 includes new
smart pointer classes: shared_ptr and the recently-added unique_ptr. Both
are compatible with other Standard Library components, so you can safely store
these smart pointers in standard containers and manipulate them with standard
algorithms.
C++11 Standard
Library:
C++11 includes new
container classes (unordered_set, unordered_map, unordered_multiset, and
unordered_multimap) and several new libraries for regular expressions,
tuples, function object wrapper and more.
Miscellaneous:
1. Lambda
Expressions
2. Automatic Type
Deduction and decltype(auto)
3. Deleted and
Defaulted Functions(default, delete)
4. nullptr
5. Delegating
Constructors
6. Rvalue
References
ref:
Intel Software Labs - Intel Software & Blogs - http://software.intel.com/
Microsoft Coding Standard Rules - http://msdn.microsoft.com/en-us/library/czefa0ke.aspx
Microsoft Coding Standard Rules - http://msdn.microsoft.com/en-us/library/czefa0ke.aspx
UTF-8 & Unicode FAQ for Unix/Linux - http://www.cl.cam.ac.uk/~mgk25/unicode.html
C++ Strings =>
The Complete Guide to C++ Strings, Part I - Win32 Character Encodings : http://www.codeproject.com/KB/string/cppstringguide1.aspx
The Complete Guide to C++ Strings, Part II - String Wrapper Classes : http://www.codeproject.com/KB/string/cppstringguide2.aspx?fid=11477&df=90&mpp=25&noise=3&sort=Position&view=Quick&fr=126&select=308883
C++ Strings - http://richardbowles.tripod.com/cpp/cpp15.htm
The Complete Guide to C++ Strings, Part II - String Wrapper Classes : http://www.codeproject.com/KB/string/cppstringguide2.aspx?fid=11477&df=90&mpp=25&noise=3&sort=Position&view=Quick&fr=126&select=308883
C++ Strings - http://richardbowles.tripod.com/cpp/cpp15.htm