Sunday, October 30, 2016

Templates in C++ simply explained.

Here are three videos that simply explain concepts of function templates, class templates and template Specialization.

1.  Function templates



2.  Class templates



3.  Template Specialization

Friday, October 28, 2016

Compilation process of a C++ program.

When we write a C++ program we use g++ -Wall -o sample sample.cpp command (file name is sample.cpp) to compile the program then we run the executable output from that process.

In this this post lets see how this compilation process happen before output an executable.

This compilation process has four main stages.
  1. Preprocessing

    In this stage preprocessor copies the contents of the included header files into the source code file, generates macro code, and replaces symbolic constants defined using #define with their values.
    Normally the standard header files to be included are in "/usr/include" directory in Ubuntu. [GCC looks in several different places for headers]
    We can stop the compilation process after preprocessing using
    g++ -E sample.cpp
    Output we get after this stage might be very long because all the header files are also included.
  2. So directing the output to a txt file would be better.
    g++ -E sample.cpp > AfterPrePros.txt

Tuesday, October 25, 2016

Some Linux Command that I found useful



Here are some linux command I found useful in my day to day work.
This is not a full list of LINUX commands. recently started working with LINUX. So this is a set of simple commands I found useful.


  • whatis

    It provides very brief descriptions of command line programs and other topics related to Linux and other Unix-like operating systems.whatis searches a set of database files containing short descriptions of system commands for keywords and displays the result
    whatis head
    whatis head tail
    
  • source

    source is a bash shell built-in command that executes the content of the file passed as argument, in the current shell. It has a synonym in '.' (period).
    source .cshrc
    
  • ls -la ~/ | more

    Find hidden files on a directory
  • Move files from one place to another

    mv /home/jack/testfile /home/jack/testfile2
    mv testfile testfile2
    mv /home/jack/testfile /home/jack/Documents/
  • Monday, October 24, 2016

    Copy constructors in C++ simple explained

    Here are three videos that explains concept of copy constructor in C++ nicely. Best I found so far.

    1. Copy constructor



    Optimize you working enviorenment : Single command to create & move to a directory in linux (C Shell, Bash)

    Usually move to a directory just after creating is bit of a anxious task specially if the directory name is too long. mkdir long-name-of...