This is the general signature of the operator[]
:
T& operator[](any_type);
In your context it would look like this:
struct str {
...
char& operator[](std::size_t pos) {
return a[pos];
}
};
More Related Contents:
- positioning pie slice problems
- How to convert a std::string to const char* or char*
- How should I write ISO C++ Standard conformant custom new and delete operators?
- Windows threading: _beginthread vs _beginthreadex vs CreateThread C++
- How to solve the 32-byte-alignment issue for AVX load/store operations?
- Defining static const integer members in class definition
- Using local classes with STL algorithms
- C/C++ unsigned integer overflow
- How to use base class’s constructors and assignment operator in C++?
- Convert float to string with precision & number of decimal digits specified?
- What is the optimal algorithm for generating an unbiased random integer within a range?
- C++ – passing references to std::shared_ptr or boost::shared_ptr
- Why do we copy then move?
- Why do we actually need Private or Protected inheritance in C++?
- Acquire/release semantics with non-temporal stores on x64
- Circular C++ Header Includes
- What is the Best Practice for Combating the Console Closing Issue?
- Compiling with -static-libgcc -static-libstdc++ still results in dynamic dependency on libc.so
- How to query a running process for its parameters list? (Windows, C++)
- Address-of operator (&) vs reference operator(&)
- C++ short-circuiting of booleans
- Can branches with undefined behavior be assumed unreachable and optimized as dead code?
- Does the restrict keyword provide significant benefits in gcc/g++?
- How to set ROI in OpenCV?
- What happens before main in C++?
- C++ Extract number from the middle of a string
- weak_ptr, make_shared and memory deallocation
- How is floating point conversion actually done in C++?(double to float or float to double)
- Using custom camera in OpenCV (via GStreamer)
- Private constructor and make_shared