Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - C++ exam questions
C++ exam questions
One. 1. When the range delimiter is limited

2. References to objects

keep intact

4.A & ltB | | A & ltC

5. Constructor with no formal parameters or default parameters

6.*** Enjoy

7. Last unpaired if pairing

8.0

9. The member functions of different derived classes and the member function names, parameter numbers,

Parameter type and return value type are the same.

10. The destructor has no parameters. Destructors can be defined as virtual functions.

1 1. The called member function is a virtual function. Call a virtual function with a pointer or reference.

12. The called member function is a virtual function. Call a virtual function with a pointer or reference.

13. Cannot modify. Cannot modify class data members.

14. Character array \0

15. input/output library Cout <<n

Second: BBC.

Three:

1. When an object contains a pointer data member and uses it to initialize another object of the same type, the default copy constructor can only copy the data member of the object to another object, but not the memory cell pointed by the pointer in the object. In this way, the same memory cell may be released twice, resulting in an error in the programming operation.

2. Member functions are defined in the class, and their scope is in the class. Member functions can access data members of the class (public, protected and private data members), call other member functions of the class (public, protected and private member functions) and call global functions. If the friend function is a public member function of another class, the member function of that class can only be called through the object of that class, but the protection and private member functions of that class cannot be called. Non-class member functions (other class member functions or global functions) can access the public data members of this class and call the public member functions of this class through the objects of this class. Not all member functions defined in a class are global functions. If a function (global function or member function of one class) is defined as a friend function of another class, then it needs to be declared with the friend keyword in that class. The friend function is not a member of this class, and its definition is naturally outside this class.

3. Structured programming separates data from data manipulation, and the program is composed of functions. Object-oriented programming encapsulates data and operations, and the program is composed of objects, which communicate with each other through interfaces, which can better support the reuse of program code.

4. Both struct and class can define classes, but when the default access right is specified, the members of struct are public and the members of class are private. In C++, struct can be replaced by class.

Four.

# include & ltiostream & gt

# contains "cmath.h"

Use namespace std

void main()

{

int max,a,I;

CIN & gt; & gtmax & gt& gta;

//Array subscripts cannot use variables.

Double x [];

for(I = 0; I & ltmaxi++)

x[I]= sqrt(a * I);

}