OBJECT ORIENTED PROGRAMMING CIS 3100

Its general form is pointer variablenew data type

This preview shows page 5 - 8 out of 54 pages.

Its general form is, Pointer variable=new data-type; • delete Memory release operator - When a data object is no longer needed it is destroyed to release the memory space for reuse.The general form is, delete pointer variable;
Image of page 5

Subscribe to view the full document.

34. List out the advantages of new operator over malloc (). • It automatically computes the size of the data object. • It automatically returns the correct pointer type. • It is possible to initialize the objects while creating the memory space. • It can be overloaded. 35. Define manipulators. What are the manipulators used in C++? Manipulators are operators that are used to format the data display. The manipulators used in C++ are • endl – causes a linefeed to be inserted • setw – provides a common field width for all the numbers and forces them to be printed right justified 36. What are the three types of special assignment expressions? • Chained assignment e.g., x = y = 10; • Embedded assignment e.g., x = (y = 50) + 10; • Compound assignment e.g., x + = 10; 37. Define implicit conversion. Whenever data types are mixed in a expression, C++ performs the conversions automatically. This process is known as implicit or automatic conversion. e.g., m = 5 + 2.75; 38. Define integral widening conversion. Whenever a char or short int appears in an expression, it is converted to an int. This is called integral widening conversion. 39. What are the control structures used in C++? • Sequence structure (straight line) • Selection structure (branching) _ if – else (two way branch) _ switch (multiple branch) • Loop structure (iteration or repetition) _ do – while (exit controlled) _ while (entry controlled) _ for (entry controlled) 40. Define Function Prototyping. The function prototype describes the function interface to the compiler by giving details such as the number and type of arguments and type of return values. It is the declaration of a function in a program. It is in the following form, type function – name (argument – list); where argument – list -> types and names of arguments to be passed to the function 41. What is call by reference? When we pass arguments by reference, the formal arguments in the called function become the aliases to the actual arguments in the calling function. Here the function works on the original data rather than its copy. e.g., void swap (int &a, int &b) { int t = a; a = b; b = t; } 42. What are inline functions? An inline function is a function that is expanded in line when it is invoked. Here, the compiler replaces the function call with the corresponding function code. The inline function is defined as,
Image of page 6
inline function-header { function body } 43. List out the conditions where inline expansion doesn’t work. • For functions returning values, if a loop, a switch, or a goto exists • For functions not returning values, if a return statement exists • If functions contain static variables • If inline functions are recursive 44. Why do we use default arguments?
Image of page 7

Subscribe to view the full document.

Image of page 8
You've reached the end of this preview.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern