Test Flashcards

0
Q
  1. Constructor declaration, can it return a type?
A

a constructor is declared by declaring a function with the same name as the class it is in. Constructors can’t return anything, not even a void.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
1
Q
  1. What is the difference between copy constructor and an assignment operator?
A

A copy constructor is used to initialize a previously uninitialized object from some other object’s data.
An assignment operator is used to replace the data of a previously initialized object with some other object’s data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
  1. Order of calling constructors
A
Base class constructors and derived class destructors are called  first.  Because the Derived class inherits from the Base class, both the  Base class and Derived class constructors will be called when a Derived  class object is created. When the main function is finished running,  the object x's destructor will get called first, and after that the Base  class destructor will be called.
Inside Base constructor Inside Derived constructor Inside Derived destructor Inside Base destructor"

The order is:

Member variables are initialized to default values for all classes in the hierarchy
Then starting with the most derived class:

Variable initializers are executed for the most-derived type
Constructor chaining works out which base class constructor is going to be called
The base class is initialized (recurse all of this :)
The constructor bodies in the chain in this class are executed (note that there can be more than one if they're chained with Foo() : this(...) etc
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
  1. Static element on initialisation list
A

A static element is created during the first initializaton of class’s object, is common (has the same value) for every object of that class, modifyng the value of static element in class means that the modified value is in every object’s of that class.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
  1. Which operators can’t be overloaded ?
A
These operators can't be overloaded:
.
sizeof
.*
?:
\::
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
  1. Map and multimap, what’s the difference ?
A
map - container from STL, in other language is hash/dictionary, it's got key value and mapped value),
#include 
map email;
email["key"]="value";

multipmap:
Key in multipmap is not unique, as it is in map

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
  1. What is a weak aggregation ?
A

One object uses another, but is otherwise independend of it (won’t be destroyed if the other one is)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
  1. Selective inheritance
A

cannot weaken or strengthen access to members/methods.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
  1. Definition of Template
A

Templates are a feature of the C++ programming language that allows functions and classes to operate with generic types. This allows a function or class to work on many different data types without being rewritten for each one.

Templates are of great utility to programmers in C++, especially when combined with multiple inheritance and operator overloading. The C++ Standard Library provides many useful functions within a framework of connected templates. (from wiki).

int tab[2][3] = {{1,2},{4}} What does this array look like? The unspecified elements of the array are set to 0.

int tab[10]; tab[9]= 10.7 what is the value of the last element of the array - the answer is 10, unless this is a trick question about the array structure or smth

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q
  1. static variable
A

Preserves variable value to survive after its scope ends.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q
  1. inheritance
A

Classes can be extended by creating new classes which retain characteristic of the base class.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q
  1. Difference between public and private inheritace
A

Public and protected members of a base class are accesible from a derived class

Objects of derived class with private and protected inheritance cannot acces any data member of a base class

Objects of derived class with public inheritance can access only public member of a base class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q
  1. Which of the functions was initiated?
A

It was declared as a virtual but as a child was private

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q
  1. Can we prevent from abort function operations.
A

We can instal the signal handler that gets called in such situation.
We can also set function _set_abort_behavior for visual c++

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q
  1. Inheritance of exceptions
A

Its a class which catch and store all possible exceptions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q
  1. Can we create two templates with same name?
A

Yes

16
Q
  1. friend template
A

Every specialization of of the template becomes a friend, whether it is implictly instantiated, partially specialized, or exlicitly specialized.

17
Q
  1. Calling function with deafult argument
A

For function which we have 3arguments If the 3rd argument is deafult, than when we call a function only with only first two arguments and the third is omitted, the deafult value will be used instead.