3i Infotech Placement: Sample Questions 807 - 808 of 1245

Glide to success with Doorsteptutor material for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

Question 807

Edit

Describe in Detail

Essay▾

Differentiate between declaration and definition in c ++ .

Explanation

  • A declaration introduces a name into the program while a definition provides a unique description of an entity (e. g. type, instance, and function) .
  • Declarations can be repeated in a given scope if they introduce the same name in a given scope but there must be exactly one definition of every object, function or class used in a C ++ program.
  • A declaration is a definition unless it
    • Declares a function without specifying its body
    • Contains an extern specifier and no initializer or function body
    • Is the declaration of a static class data member without a class definition
    • Is a class name definition
    • Is a typedef declaration
  • A definition is declaration unless it:
    • Defines a static class data member,
    • Defines a non-inline member function.

Question 808

Edit

Describe in Detail

Essay▾

When can you tell that a memory leak will occur?

Explanation

  • A memory leak occurs when a program cannot free a block of dynamically allocated memory.
  • When program creates memory using constructor but fails to call destructor for release or free- causing memory leakage
  • Programmers allocate memory in heap and forget to delete it. Memory on stack is automatically managed.
  • Memory leaks are serious for programs like deamons and servers which never terminate.
Given the Image is Function with Memory Leak

Developed by: