Is the mall
a. both struct and class can be used to define abstract data types (ADI),
difference between the two? A class can create sub classes that inherits a
Parents Properties, and struct con not
b. the following data structure and its object array (i.e. data p[3]) are defined in a 64 bit
operating system, what's the size of the array? If the starting address of the array is 100,
what's the address of p[0].a, what's the address of p[0].c, and what's the address of p[2]?
struct data
{
int a;
int * b;
double c;
};
data p[3];
2. (5 points) the following program defines an abstract data type named AA, what will be
the output of the program? Show calculation details.
#include <iostream>
using namespace std;
int g = 1;
class AA
{
int *p;
public: AA ()
~AA ()
{ g++; p = &g; }
{ g++; cout << *p << endl; }
int fun(int &x, int y) { g++; x++; return g + y;}
};
int main ()
{
int a = 2, b = 3;
AA c;
b = c.fun (a, b);
}
cout << a <<<b<<<g << endl;
return 0;