Wednesday, February 23, 2011
Templates in c++ and multiple-file projects
When projects grow it is usual to split the code of a program in different source code files. In these cases, the interface and implementation are generally separated. Taking a library of functions as example, the interface generally consists of declarations of the prototypes of all the functions that can be called. These are generally declared in a "header file" with a .h extension, and the implementation (the definition of these functions) is in an independent file with c++ code.
Because templates are compiled when required, this forces a restriction for multi-file projects: the implementation (definition) of a template class or function must be in the same file as its declaration. That means that we cannot separate the interface in a separate header file, and that we must include both interface and implementation in any file that uses the templates.
Since no code is generated until a template is instantiated when required, compilers are prepared to allow the inclusion more than once of the same template file with both declarations and definitions in a project without generating linkage errors.
Tuesday, February 22, 2011
Religion in ancient India
Indian spirituality is deeply rooted in the ancient philosophical and religious traditions of the land. Philosophy arose in India as an enquiry into the mystery of life and existence. A parallel situation arose in ancient Greece also. But, as Swami Vivekananda pointed out, the Greek philosophers confined their enquiries to the external world, and the method they employed was only speculation, whereas in India philosophical enquiries were carried out in the inner world. Indian sages, called Rishis or ‘seers’, developed special techniques of transcending the senses and the ordinary mind, collectively called Yoga. With the help of these techniques they delved deep into the depths of consciousness and discovered important truths about the true nature of man and the universe.
The sages found that man’s true nature is not the body or the mind, which are ever changing and perishable, but the spirit which is unchanging, immortal, pure consciousness. They called it the Atman. The Atman is man’s true Self, the true knower, the true source of man’s knowledge, happiness and power. The Rishis further found that all individual selves are parts of infinite Consciousness which they called Brahman. Brahman is the ultimate Reality, the ultimate cause of the universe. Ignorance of man’s true nature is the main cause of human suffering and bondage. By gaining correct knowledge of Atman and Brahman it is possible to become free from suffering and bondage and attain a state of immortality, everlasting peace and fulfilment known asMukti.
Religion in ancient India meant a way of life which enabled man to realize his true nature and attain Mukti.