Main Menu
Popular Articles
C++ Tutorials/ C - Aptitude Papers
- 12-16-2007
- Categorized in: C & CPP
C language is one of the traditional computer languages. It is one of the basic computer language to be learnt by everyone before entering the big software world. Though it is basic, the concepts of C are widely accepted and used in all other computer languages like Java etc. The attachment consists of C++ tutorials and aptitude questionnaire with answers which can act as a guide for the starters/learners of C.
Following is the snapshot of the C++ tutorials. Refer the document in the attachment for further explanations
C++ Namespaces
INTRODUCTION TO NAMESPACES - PART 1
Namespaces are a relatively new C++ feature just now starting to appear in C++ compilers.
We will be describing some aspects of namespaces in subsequent newsletters.
What problem do namespaces solve? Well, suppose that you buy two different generalpurpose
class libraries from two different vendors, and each library has some features that
you'd like to use. You include the headers for each class library:
#include "vendor1.h"
#include "vendor2.h"
and then it turns out that the headers have this in them:
// vendor1.h
... various stuff ...
class String {
...
};
// vendor2.h
... various stuff ...
class String {
...
};
This usage will trigger a compiler error, because class String is defined twice. In other words,
each vendor has included a String class in the class library, leading to a compile-time clash.
Even if you could somehow get around this compile-time problem, there is the further
problem of link-time clashes, where two libraries contain some identically-named symbols.
The namespace feature gets around this difficulty by means of separate named namespaces:
// vendor1.h
... various stuff ...
namespace Vendor1 {
class String {
...
};
}
Following is the snapshot of the document of the C- aptitude. Please refer the attachment for complete set of aptitude papers.
Predict the output or error(s) for the following:
1. void main()
{
int const * p=5;
printf("%d",++(*p));
}
Answer:
Compiler error: Cannot modify a constant value.
Explanation:
p is a pointer to a "constant integer". But we tried to change the value of the
"constant integer".
Attachments
Related Links
- Download technical Questions and Tutorials in C & C++
- Test your C & C++ skills
- Programming question and answers in C Language
- Programming question and answers on C++
- C Programming Notes
Comments (139)
Email to Friend
Fill in the form below to send this article to a friend:
