Tuesday, February 07, 2012

About Yantrix

Yantrix is a product development and consultancy company. 

Yantrix products are based on simple ideas with a high utility potential to make life a little easier. Yantrix consultancy helps those involved in developing higher end products to get the right technical architecture around which their inhouse teams can build the product.

In terms of  the value delivered, Yantrix products and consultancy services are highly cost effective in terms of time, energy as well as money saved.


Tuesday, April 19, 2011

A simple shell script to handle signals

#! /bin/bash
handle () {
     echo "received signal:$1"
}
term () {
     echo 'will terminate in 5 seconds ...'
     sleep 5
     exit
}
echo "pid: $$"
trap "handle HUP"  HUP
trap "handle USR1" USR1
trap "term" TERM

while true
do
    sleep 3
done
kill  -SIGHUP    
kill  -SIGUSR1  
kill  - SIGTERM 

Friday, March 25, 2011

Funny fact about a C/C++ array!

An array element is normally accessed as A[n] where A is the array var name and n is the subscript. But the following works with most C/C++ compilers!

#include
using namespace std;
int main()
{
    int A[3]={0,1,2};
   cout << 0[A] << ":" << 1[A] << ":" << 2[A] << endl;
    return 0L; 
}

output: 0:1: 2
 


Tuesday, March 22, 2011

Use of Typename keyword

When your code uses a type from a templatized class, the compiler must be made aware of it. This is where typename comes in:

#include
using namespace std;


int iter=10; //global int variable 
class Test1
{
    public:
           static int iterator;  //public static variable - can be used for calculation
};
int Test1::iterator=0;
class Test
{
    public:
        class iterator //public nested class can - declare variable with it
        {};
        iterator it;
};
template <class T>
void func()
{
       typename  T::iterator * iter; 
       //do we mean use Test::iterator - the static var
       //or Test1::iterator - user defined type
       //typename indicates we mean the type Test1::iterator 
       //else  Test::iterator static var would have been used
}       
int main()
{
   func<Test>();
//   func<Test1>();   //unmarking this gives compile time error
}