50 must-know things about C++ language continued … PART 2

let’s go on further …

6. New keywords added in C++ with respect to C language:

    those which are object oriented specific (class, public, protected, private, this, friend, virtual, template, operator)
    those related to the new dynamic memory allocation (new , delete)
    those related to exception mechanism (try, throw, catch)
    those related to different cast types (dynamic_cast, static_cast, const_cast, reinterpret_cast)
    and few others (inline, bool, explicit, namespace, mutable, true, false, using)

Small mentions:

    C89 standard borrowed from C++ const and volatile and function prototyping
    C99 standard borrowed from C++ standard the keyword inline
    C99 introduced a number of new features that C++ does not support, such as variable-length arrays, native complex-number types, designated initializers and compound literals

7. C++, in disregard with C, has namespaces. This is a feature that allows to group different programming entities, like class, objects, functions, under the same name. All the files in the C++ standard library declare all of its entities (including cout and cin) within the std namespace. This is the reasonwhy anytime we’re using in C++ programs classes or functions comming from standard library we must declare the namespace: using namespace std;

8. C++ allow default parameters, the programmer may call a function without explicitly specifing all the arguments that were defined for that function, the compiler fills in missing arguments, in case of C language you must specify the complete list of arguments.

9. Object Oriented programming vs Procedural programming Object-oriented programming has roots that can be traced to the 1960, so far before C++ came into existence. Object Oriented programming is a consequence of increasing complexity of software and decreasing cost of hardware. Object Oriented methodology focuses on data rather than processes, with programs composed of self-sufficient modules (objects) each containing all the information needed to manipulate its own data structure.

This is in contrast to the existing procedural programming (the one C language belongs to) which had been dominant for many years that focused on the function of a module, rather than specifically the data. An object-oriented program may thus be viewed as a collection of interacting objects, as opposed to the conventional model, in which a program is seen as a list of tasks (subroutines) to perform.

Object Oriented programming focuses more on what is to be done, what needs to be solved, in the meantime procedural programming focuses on how is to be done or how can be solved .  (Personally I think that it is like, as I stressed in bold – How vs What).

10. What is the difference between class and object ? … maybe a stupid question, will think someone of you. Class is an abstract entity which holds all the characteristics (methods) of its elements (members).

An object is a particular instance of the class, is like considering the notion of “Animal” (a general element) to be a class and a certain Animal (like Cat or Dog) to be the object of the corresponding class. When declaring a class there is no storage alocated on the disk, this happens when corresponding class is instantiated, when an Object is created.

11. This pointer (not this one the other one:) ) – is a hidden pointer to the current object which all member functions take it as an invisible parameter. It enables pointer access of the members to the member functions of the class. It is not counted for calculating the size of the object.

12. Static members and methods. In the context of objects and classes static keyword gets an additional meaning. We can speak about static members and static methods. A static memberhas a quite similar meaning to the one of static local variables from C. Its lifetime is not limited by the lifetime of the object that it owns it, but it passes away when program finishes. Actually static members are different from the rest of the class members. They have a different storage place than rest of the class members so it is unapropiate to say that an object owns a static member. They are more member of the class than members of a certain object instance, when want to access them you do not have to declare an object of that class, you access them via the class name. Static methods have pretty much the same proprieties as static members, they do not belong to an object instance and are called via the class name, so as a conclusion they do not receive this (we’ve already discussed) parameter.

One rule about static members: do not initialize them inside the class.

Enough for this post … will continue next time.


One Response to 50 must-know things about C++ language continued … PART 2

  1. I really liked reading your post!. Quallity content. With such a valuable blog i believe you deserve to be ranking even higher in the search engines :). Check out the link in my name. That links to a tool that really helped me rank high in google. This way even more people can enjoy your posts and nothing beats a big audiance 😉

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: