

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
This is code for a lab task of Data Structures course. Its main topic is Class Arrays. It was submitted to Amar Kumar at Amrita Vishwa Vidyapeetham. It includes: Class, Arrays, Protected, Unsigned, Public, Store, Retrieve, Size, Illegal, Operation, Return
Typology: Summaries
1 / 2
This page cannot be seen from the preview
Don't miss anything!


class arrays { protected: char *p; unsigned int size; public: arrays(unsigned int x); void store(unsigned int index, char value); char retrieve (unsigned int index); unsigned int get_size(); };
void arrays::arrays (unsigned int x) { p = new char[x]; size = x; } { void arrays::store(unsigned int index, char value)
if (index >= size) { cout << "Illegal Operation\n"; return; } *(p+index) = value; } char arrays::retrieve(unsigned int index) { if (index >= size) { cout << "Illegal Operation\n"; return -1; } return *(p+index); } unsigned int arrays::get_size() { return size; }