Appian Corporation C++ Interview Questions Answers

Explain The Scope Resolution Operator?

It permits a program to reference an identifier in the global scope that has been hidden by another identifier with the same name in the local scope.

How Do You Link A C++ Program To C Functions?

By using the extern "C" linkage specification around the C function declarations.

How Do I Initialize A Pointer To A Function?

This is the way to initialize a pointer to a function

void fun(int a)
{
void main()
{
void (*fp)(int);
fp=fun;
fp(i);
}
}

What Does Extern Mean In A Function Declaration In C++?

It tells the compiler that a variable or a function exists, even if the compiler hasn't yet seen it in the file currently being compiled. This variable or function may be defined in another file or further down in the current file.

How Do I Declare An Array Of N Pointers To Functions Returning Pointers To Functions Returning Pointers To Characters?

If you want the code to be even slightly readable, you will use typedefs.

typedef char* (*functiontype_one)(void);
typedef functiontypeone (*functiontype_two)(void);
functiontype_two myarray[N]; //assuming N is a const integral

What Is The Auto Keyword Good For In C++?

Local variables occur within a scope; they are "local" to a function. They are often called automatic variables because they automatically come into being when the scope is entered and automatically go away when the scope closes. The keyword auto makes this explicit, but local variables default to auto auto auto auto so it is never necessary to declare something as an auto auto auto auto.

What Is The Difference Between Char A[] = "string"; And Char *p = "string";?

In the first case 6 bytes are allocated to the variable a which is fixed, where as in the second case if *p is assigned to some other value the allocate memory can change.
Appian Corporation Most Frequently Asked C++ Interview Questions Answers
Appian Corporation Most Frequently Asked C++ Interview Questions Answers

What Can I Safely Assume About The Initial Values Of Variables Which Are Not Explicitly Initialized?

It depends on complier which may assign any garbage value to a variable if it is not initialized.

What Does Extern Mean In A Function Declaration?

Using extern in a function declaration we can make a function such that it can used outside the file in which it is defined.

An extern variable, function definition, or declaration also makes the described variable or function usable by the succeeding part of the current source file. This declaration does not replace the definition. The declaration is used to describe the variable that is externally defined.

If a declaration for an identifier already exists at file scope, any extern declaration of the same identifier found within a block refers to that same object. If no other declaration for the identifier exists at file scope, the identifier has external linkage.

What Is The Best Way To Declare And Define Global Variables?

The best way to declare global variables is to declare them after including all the files so that it can be used in all the functions.

How Do You Decide Which Integer Type To Use?

It depends on our requirement. When we are required an integer to be stored in 1 byte (means less than or equal to 255) we use short int, for 2 bytes we use int, for 8 bytes we use long int.

A char is for 1-byte integers, a short is for 2-byte integers, an int is generally a 2-byte or 4-byte integer (though not necessarily), a long is a 4-byte integer, and a long long is a 8-byte integer.

Anything Wrong With This Code?

t*p = 0;
Delete P;


Yes, the program will crash in an attempt to delete a null pointer.

Anything Wrong With This Code?

t *p = Newt[10];
Delete P;


Everything is correct, Only the first element of the array will be deleted", The entire array will be deleted, but only the first element destructor will be called.

What Problems Might The Following Macro Bring To The Application?

#define sq(x) x*x

What Is An Html Tag?

An HTML tag is a syntactical construct in the HTML language that abbreviates specific instructions to be executed when the HTML script is loaded into a Web browser. It is like a method in Java, a function in C++, a procedure in Pascal, or a subroutine in FORTRAN.

Why Are Arrays Usually Processed With For Loop?

The real power of arrays comes from their facility of using an index variable to traverse the array, accessing each element with the same expression a[i]. All the is needed to make this work is a iterated statement in which the variable i serves as a counter, incrementing from 0 to a. length -1. That is exactly what a loop does.

What Is Polymorphism In C++? Explain With An Example?

"Poly" means "many" and "morph" means "form". Polymorphism is the ability of an object (or reference) to assume (be replaced by) or become many different forms of object. Example: function overloading, function overriding, virtual functions. Another example can be a plus '+' sign, used for adding two integers or for using it to concatenate two strings.

What Do You Mean By Pure Virtual Functions?

A pure virtual member function is a member function that the base class forces derived classes to provide. Normally these member functions have no implementation. Pure virtual functions are equated to zero.

class Shape
{
public: virtual void draw() = 0;
};

What Is A Scope Resolution Operator?

A scope resolution operator (::), can be used to define the member functions of a class outside the class.

What Is The Difference Between An External Iterator And An Internal Iterator? Describe An Advantage Of An External Iterator?

An internal iterator is implemented with member functions of the class that has items to step through. .An external iterator is implemented as a separate class that can be "attach" to the object that has items to step through. .An external iterator has the advantage that many difference iterators can be active simultaneously on the same object.

What Are Virtual Functions In C++?

A virtual function allows derived classes to replace the implementation provided by the base class. The compiler makes sure the replacement is always called whenever the object in question is actually of the derived class, even if the object is accessed by a base pointer rather than a derived pointer. This allows algorithms in the base class to be replaced in the derived class, even if users don't know about the derived class.

What Is Abstraction In C++?

Abstraction is of the process of hiding unwanted details from the user.

Post a Comment

Previous Post Next Post