| [ Web Proxy ] |
| Viewing: https://raw.githubusercontent.com/learncppnow/9E/main/12.10%20ArraySubscriptOperator_MyString.cpp | [Back] [Original] |
#include
#include
using namespace std;
class MyBuffer
{
private:
int* myNums;
unsigned int bufLength;
public:
MyBuffer(unsigned int length)
{
bufLength = length;
myNums = new int[length]; // allocate memory
}
int& operator[] (unsigned int index)
{
return myNums[index];
}
// const version will be used by const instances of MyBuffer
const int& operator[] (unsigned int index) const
{
return myNums[index];
}
MyBuffer(const MyBuffer& src)
{
cout
| Web Proxy Viewer | New URL | Original Page |