The questions of Middle Test
with two possible answers - one correct (yes) and one incorrect (no)


Mark the correct/incorrect assertions about pointers.

(yes)
A pointer denotes the location of a variable in memory.
(no) The value of a pointer must be an address in the heap memory.



Mark the correct/incorrect pointer definitions.

(no)
  int* my_p;
(yes) int p = new int;




We have the following variable definitions:

    int p = 2;
    int* pt1;
    int* pt2 = new int(10);

Mark the correct/incorrect assignment statements.

(yes) pt1 = pt2;

(no) 
pt1 = *pt2;



We have the following variable definitions:

    int a[3] = {10, 20, 30};
    int* pa = a;


Mark with ``yes'' expressions which have value 30.

(no)  a[0] + a[1]
(yes) *a



Mark the correct/incorrect assertions about classes.

(yes) A constructor always has the same name as the class name.
(no) The main function can access directly the private data members of a class.



Mark with "yes'' a function declaration which can be used as a constructor of a class.
(Remember that the constructor name coincides with the class name.)

(yes) Point(double x, double y);
(no)  int Time();



We have a class:
class Product {
public:
Product();
Product(string n, double p, int s);
void read();
string get_name() const;
double get_price() const;
void print() const;
private:
string name;
double price;
int score;
};
and an object p of this class, constructed in main function. Mark the correct/incorrect statements in the body of main function.

(yes) Product p22;
(no)  cout << p.name;



Mark the correct/incorrect assertions about stream library operators and functions.

(yes) To read or write files, you use variables of type fstream, ifstream, or ofstream.
(no) The << operator is defined for ifstream objects..



We have the following file variables:

ifstream fin;
ofstream fout;
fstream f;

and the variables:

int k = 10;
double x = 15.5;
char ch = 'N';
string s = "alabala";

Mark the syntax correct/incorrect statements.

(yes)fout << x << " " << s;
(no) fout >> x;


Mark the correct/incorrect statements about the class CashRegister and the object register1 of this class.

(yes)get_total() is an accessor member function.
(no) register1.clear() is the declaration of the function clear().