






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A portion of the course materials for cmsc 433, a university of maryland computer science course taught by william pugh. It covers various aspects of c++ programming, including the use of references, dynamic memory allocation using new and delete, and data abstraction using classes and object-oriented programming. Topics include c++ without classes, references, new/delete, data abstraction, access control, and virtual functions.
Typology: Exams
1 / 11
This page cannot be seen from the preview
Don't miss anything!







1
Programming Language Technology and Paradigms
2
3
4
5
int x,y; int *p = &x; int &q = y; q++; // increments y p++; // increments p, returns value of x (p)++; // increments x q = x; // assigns value of x to y p=&y; // makes p point to y; 6
7
void IA_init(IntArray *ia); void IA_cleanup(IntArray * ia); void IA_setSize(IntArray * ia, int value); int IA_getSize(IntArray * ia); void IA_setElem(IntArray * ia, int index, int value); int IA_getElem(IntArray * ia, int index);
class IntArray{ public: IntArray(); ~IntArray(); void setSize(int value); int getSize(); void setElem(int index, int value); int getElem(int index); …} (^8)
void IA_init(IntArray *ia); void IA_cleanup(IntArray * ia); void IA_setSize(IntArray * ia, int value); int IA_getSize(IntArray * ia); void IA_ setElem(IntArray * ia, int index, int value); int IA_getElem(IntArray * ia, int index);
9
10
11
19
IntArray& operator=(const IntArray &a) { if (this == &a) return this; if (size != a.size) { delete [] rep; rep = new int[a.size]; size = a.size;} memcpy(rep, a.rep, sizeof(int)size); return *this; }
}
20
21
23
25
// B::operator=(const B&) // Illegal (why?) // B::operator=(const B&) // B::operator=(const B&) (^26)
27
29
30
37
38
39
40
41
42
43
44
45
47
48
55
57
58
59
60
61
62
63
64