dailyterew.blogg.se

Challenging c debugging questions
Challenging c debugging questions











Ět the time of passing by value as an argument to a function by the object of that class.If a function is returning an object of that particular class by value.Ět the time of generating a temporary object by the compiler.If we don't implement copy constructor, it does automatically.Ĭopy constructors are called in these scenarios below:.With a different object of the same class, it initializes it's object member variable.The constructor with a single argument is called as conversion constructor and it can be used for the type conversion.ī B Object = 10 // assigning int 10 B object.List x() // function which returns the List Then function f() evokes a local List object x:īut the function g() invokes f() which eventually returns a List:

Challenging c debugging questions code#

There exists a big difference which is explained via a code below: b) A type can be converted to the correct typeĮxplain the differences between List x & List x().a) If the actual argument is the correct type, but it isn't Lvalueĭouble value = cubes(3.0 + temp) // the argument is said to be an expression ,not the Lvalue.If the function parameter is a "const reference", the compiler generates temporary variables in the following 2 ways. When does the C++ compiler create temporary variables? So, if NestedClass is when public ,any code can be named as OuterClass::NestedClass. Nested classes are of great use for organizing code and for controlling access and dependencies.Ě nested class is said to be a class which is enclosed in the scope of another class.If this occurs, we can confirm that the linked-list is a cycle else not.ĭefine a nested class. Incase there is a cycle, the one that goes 2 nodes each time will meet the one that goes slower.Ğach time when the second one goes at node 1.We can find out if the linked-list is cycle or not by the use of two pointers: How come you find out if a linked-list is a cycle or not? The destructor calls all the local objects between the place where the exception had been thrown and where it had been caught.It takes place when the destructor is being called.Stack unwinding is the process for exception handling.Name the different types of STL containers. This is approved by the ANSI committee for including in the standard C++ specification.It is the library for container templates.STL stands for Standard Template Library.The linkage is done in the C function declarations.ğirst by using the extern "C" linkage specification.How can you link a C++ program to C functions? The variable or function can be defined within another file.The extern tells the compiler regarding the existence of a variable or a function.Incase of a function declaration, what is extern means? The program will be crashed for an attempt to delete a null pointer.With the help of an external iterator many different iterators can be activated simultaneously on the same object.In case of an internal iterator it is implemented with a member function of the class which are having the items to step through.Ěn external iterator gets implemented as a separate class that can be "attach" to the object which is having items to step through.Write some differences between an external iterator and an internal iterator? Describe the advantage of an external iterator. The base class is called abstract classĮxample of a pure virtual function or abstract class this way. While we define function prototype in a base class without implementation. What is pure virtual function? or what is abstract class? #define min(i, j) ( i show() // calls parent->show() i If macro parameter is having a post incremented variable ( like c++ ), the increment will be performed twice.The macro can be expanded without any special type checking.There is no way for the compiling to verify that the macro parameters are of compatible types.If an array of objects are created using new, then delete will be dealing with an array by preceding the name & with an empty :. "delete" first calls the object's termination routine and then releases the space the object occupied on the heap memory.New and delete,both can be overloaded in a class : int *p = ( int * ) ( malloc ( sizeof(int) ) ).string * ptr = (string *)(malloc (sizeof(string))).malloc() and free() are not able to support object semantics but does not construct and destruct any objects.new also allocates thememory and also invokes constructor to initialize the object.The malloc allocates memory for object in the heap but not invokes object's constructor for initiallizing the object.What is diff between malloc()/free() and new/delete? Ě class may be having a public method for the specific data type conversions.ĭouble i = BObject // the conversion operator is called to assign the value.Explain the public method for the data type conversions.











Challenging c debugging questions