Sie sind auf Seite 1von 7

Avatto

When C++ was developed. it did not have a compiler.


It used cfront, which translated the C++ code into a C code and then the existing C compiler was
used to compile the program originally written in C++.

Procedural languages sequentially execute a set of imperative statements to achieve the desired
effect => Pascal & c.

Reusability is a desirable feature of a language as it =>decreases the testing time ,compilation


time

?: & . =>operators cannot be overloaded.

Overloading is otherwise called as => Ad-hoc polymorphism

cout stands for => Console o/p.

The fields in a structure of a C program are by default => Public

Forgetting to include a file (like cmath or math.h) that is necessary will result in => Compiler
error

A function is declared inline by typing the keyword inline before the return value of the function.
A function that is declared inline may not be treated inline
It speeds up execution & increases code size.

Register and inline are not compiler directives but rather request to the compiler. These requests
need not be honored by the compiler.

Class & function can not be static while Object can.

The order in which operands are evaluated in an expression is predictable if the operator is => &&
the order of evaluation for the operator & & is defined by the language. It evaluates from left to right.
Do not confuse order of evaluation with associativity.

A class having no name:


• cannot be passed as an argument.
• cannot have constructor, destructor.

In a struct, the access control is public by default.


In a class, the access control is private by default.
Constructors can take arguments but destructors cannot.
Constructors can be overloaded but destructors cannot be overloaded.

A constructor,destructor is not inherited.


A constructor cannot be called explicitly.

:: is basically meant to manipulate a global variable, in case a local variable also has the same
name.

void abc (int x=0, int y=0) => Both the arguments are optional. All the calls are legal.

The symbol << has a context sensitive meaning. The << in (a << 2) means shifting a by 2 bits to the
left, which is nothing but multiplying it by 4. So, a < <2 will be 5 x 4 = 20.

storage class supported by C++ => Register, auto, mutable but not dynamic.

const char *p1= "To make the bitter butter better" ; // stm1
char *const p2 = "Recommend this book 2 others ";//stm2
p1 = "add some better butter not bitter. " ;//stm3
p2 = "so that th~y 2 will get benefited. " ; //stm4 → Error
* (p1+3) = 'A' ; //stm5 → Error
* (p2+3) = 'A' ;

If many functions-have the same name, which of the following information, if present, will be used by
the compiler to invoke the correct function to be used. => The operator : : && Function signature.

void abc(int x=0, int y, int z=0) => abc () ; , abc (h) ; => error calling
Since the second argument is mandatory, any call should have at least the first two parameters.
Some compilers expect the optional parameters to follow the others. Such compilers give a
compilation error.

The compiler identifies a virtual function to be pure => if it is equated to 0.

As such C does not support pass by reference but c++ does. But it can be simulated by using
pointers.
Assume that the random number generating function - rand( ), returns an integer between 0
and 10000 (both inclusive). If you want to simulate the throwing of a die using this random
function, use the expression => rand ( ) % 6 + 1.
It should randomly generate any integer between 1 and 6. rand( ) % 6 returns an integer from 0 to 5.
To make it 1 to 6, we need to add 1.

Assume that the random number generating function - rand( ), returns an integer between 0
and 10000 (both inclusive). To randomly generate a number between a and b (both inclusive),
use the expression => (rand( ) % (b-a+l)) + a

An example will help you understand. Let a be 6 and b be 10. There are 5 numbers between 6 to 10
(both inclusive). This is b-a+ 1 (10 - 6 + 1). rand( ) % (b - a + 1) returns an integer from 0 to (b - a). To
make it a to b, add a, giving rand() % (b-a+ 1) + a.

Compiler decides if a function that is declared inline is indeed going to be treated inline in the
executable code.

type of functions is an ideal candidate for being declared inline => A function that is small and is
called frequently.

One of the disadvantages of pass-by reference is that the called function may inadvertently
corrupt the caller's data. This can be avoided by => declaring the formal parameters constant.

If the formal parameters are declared constants, the compiler will not allow any changes to be made.
So the question of inadvertently corrupting the caller's data, does not arise at all.

A function that does the same operation on different data types is to be implemented using =>
Function Template.

A dumb terminal has => in the class declaration section.


Data hiding is used to create => private class members

A. inline functions
private class members
B.

C. nonscalar type
cryptic code
D.

Creating a class definition when one class is granting friendship to a function that is a member
of another class requires first => a forward declaration of the class that is granting friendship.

Forcing a variable type to become another type before accessing an appropriate function is called
=> coersion

Without overloading of the + operator, => programs would be harder to read and understand.
But can be addition can be performed on class objects by individual member adding.

Which of the following operators may be overloaded => D


.(Member)
A.

B. ::(scope resolution)
%(Modulus)
C.

D. ?:(conditional)

Which of the following may be overloaded as an operator => D

A. operator*()
*operator()
B.

C. op*()
*op()
D.
The name of the operator function that overloads the * symbol is => operator*()

Assuming that properly overloaded the / operator for a Number class, and that a and b are two
members of the Number class, which expression is legal => Both
A. a/b
a operator/ (b)
B.

Assuming that properly overloaded the *operator to perform multiplication for a Number
class, and that a, b, and c are three members of the Number class, which expression is legal =>
All
A. a*b
a*b*c
B.

If an operator is normally defined to be only unary, then one => may nt overload it.

When you overload operators, you may change => binary operators to unary ones but not
associativity & precedence.

To perform multiple arithmetic operations in a single statement, overloaded operator


functions should return => an object of the class type

best function prototype for an overloaded ........... for a Number class => Number operator-(const
Number & num)

A usable function header for an overloaded » operator for a Number class is => friend istream &
operator» (istream & in, Number & num)

If ++ operator is overloaded properly, then operator ++ () function returns => a reference to a


class member data item.

Object-oriented programmers primarily focus on => objects and the tasks that must be performed
with those objects.

best prototype to overload the « operator for a Number class => friend ostream & operator«
(ostream & out, const Number &num);
If subscript operator has been correctly overloaded for a Number class to accept an integer
value, and num is a member of the number class, => num = [44].

language has the capability to produce new data type => extensible

An inline function=> which is defined inside a class, consist of small code.

namespace is used in c++ by default => std

class can be defined and used inside a function are known as => local class

function and variable are collective of a class called as => class member

Binding of data and function together into a single class is known as =>
encapsulation, data binding

class is user defined data type.

if we are using the same function name to create function that performs a
variety of different tasks this is known as => function overloading, function
polymorphism

reference variable in c++ => to create the alias name of particular variable and
operator.

c++ developed by => bjarne stratroup & 1980

default return type for all function in c++ => integrated

c++ is a =>top down programming approach

Das könnte Ihnen auch gefallen