We Should Not Delete This Pointer. This Pointer Always Contains The Address of The Object

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

C/C++ Questions

1. What is the output of printf("%d") GARBAGE VALUE 2. What will happen if I say delete this we should not delete this pointer. This pointer always contains the address of the object in the scope. Deleting this pointer is like cutting a tree branch by standing on the same. This pointer is not used to access static functions, since static function is for a class not for an object.

3. Difference between "C structure" and "C++ structure". C-structure is based on collection of various data types in a single unit. It is open to all. while C++ structure is " class " which contains all functions of c and additional features as data binding and data hiding

4. Diffrence between a "assignment operator" and a "copy constructor"

A copy constructor constructs a new object by using the content of the argument object. An overloaded assignment operator assigns the contents of an existing object to another existing object of the same class.

5. What is the difference between "overloading" and "overriding"? overloading refers to -same name but different definitions and parmeters. Overriding refers to --'replacement' of methods.

6. Explain the need for "Virtual Destructor". 7. Can we have "Virtual Constructors"? 8. What are the different types of polymorphism? 9. What are Virtual Functions? How to implement virtual functions in "C" 10. What are the different types of Storage classes? 11. What is Namespace? 12. What are the types of STL containers?. Standard Template Library: Containers A container is a holder object that stores a collection of other objects (its elements). They are implemented as class templates, which allows a great flexibility in the types supported as elements. The container manages the storage space for its elements and provides member functions to access them, either directly or through iterators (reference objects with similar properties to pointers).

13. Difference between "vector" and "array"? 14. How to write a program such that it will delete itself after exectution? 15. Can we generate a C++ source code from the binary file? 16. What are inline functions? 17. What is "strstream" ? 18. Explain "passing by value", "passing by pointer" and "passing by reference" 19. Have you heard of "mutable" keyword? The mutable keyword can only be applied to non-static and non-const data members of a class. If a data member is declared mutable, then it is legal to assign a value to this data member from a const member function.

20. What is a "RTTI"? In programming, RTTI (Run-Time Type Information, or Run-Time Type Identification) refers to a C++ system that keeps information about an object's data type in memory at runtime. Run-time type information can apply to simple data types, such as integers and characters, or to generic objects.

21. Is there something that I can do in C and not in C++? 22. What is the difference between "calloc" and "malloc"? 23. What will happen if I allocate memory using "new" and free it using "free" or allocate sing "calloc" and free it using "delete"? 24. Difference between "printf" and "sprintf".

sprintf: This Writes formatted data to a character string in memory instead of stdout

The only difference between sprintf() and printf() is that sprintf() writes data into a character array, while printf() writes data to stdout, the standard output device

25. What is "map" in STL? 26. When shall I use Multiple Inheritance? 27. Explain working of printf.

28. 29. Talk sometiming about profiling? 30. How many lines of code you have written for a single program? 31. How to write Multithreaded applications using C++? 32. Write any small program that will compile in "C" but not in "C++" 33. What is Memory Alignment? 34. Why preincrement operator is faster than postincrement? 35. What are the techniques you use for debugging? 36. How to reduce a final size of executable?

37. Give 2 examples of a code optimization.

You might also like