1. Which of the following will dynamically allocate a double? a. double* ptr-=double x; b. double* ptr-double x(0); c. double* ptr=new double; d. none of the above
Addition of Two Numbers
Adding two numbers in programming is essentially the same as adding two numbers in general arithmetic. A significant difference is that in programming, you need to pay attention to the data type of the variable that will hold the sum of two numbers.
C++
C++ is a general-purpose hybrid language, which supports both OOPs and procedural language designed and developed by Bjarne Stroustrup. It began in 1979 as “C with Classes” at Bell Labs and first appeared in the year 1985 as C++. It is the superset of C programming language, because it uses most of the C code syntax. Due to its hybrid functionality, it used to develop embedded systems, operating systems, web browser, GUI and video games.
![1. Which of the following will dynamically allocate a double?
a. double* ptr=double x;
b. double* ptr=double x(0);
c. double* ptr=new double;
d. none of the above
2. Copy constructors are generally required for a class when
3.
a. For all classes
b.
When the class contains members that point to dynamically allocated memory
c. When the class is passed by reference to a non-member function and the values
are changed
d. None of the above
are member functions that are called automatically when
an object of the class type is instantiated and the
object goes out of scope
is called when that
4. Given the following statement: float* ptr=new float[10]; The proper syntax to deallocate
the memory is
a. delete ptr
b. delete[] ptr;
c. delete ptr[];
d. none of the above
5. The difference between opening a file in ios::app mode, versus ios::out mode is that
a. app mode will append data to the end of the existing data in the file while out
mode will destroy the existing data in the file.
b. App mode will not create the file if it does not already exist.
c. Opening a file in out mode will fail if the file already exists.
d. None of the above
6. A friend function is a function that is
a. Not part of the class
b. Has access to the private members and member functions of the class
c. Both a and b
d.
None of the above](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F298aa5db-21d9-479e-aac5-153a1acb17c3%2Fc68e376f-b7ef-421c-b44e-e54621a687d5%2F2rk743h_processed.png&w=3840&q=75)

Trending now
This is a popular solution!
Step by step
Solved in 2 steps









