Я пытаюсь обмануть константность переменных-членов класса. Итак, у меня есть следующий код:
"StringView.hh":
#pragma once
#include
class StringView {
public:
const char* _begin = nullptr;
const char* _end = nullptr;
explicit StringView(const char* str) : _begin(str), _end(str + strlen(str)) {}
};
main.cpp:
#include
#include "StringView.hh"
int main() {
char str[] = "cat";
StringView sv(str);
std::cout
Подробнее здесь: https://stackoverflow.com/questions/787 ... by-pointer