C++ Logo


Advanced search

[std-proposals] Namespace with access specifiers in class interface

From: Smith, Jim <jim.smith_at_[hidden]>
Date: Mon, 07 Nov 2022 20:17:06 +0000

Sometimes I'd like to hide data from a subset of class methods while still allowing other methods to access them. Also it would be helpful to set read/write access on class data for certain methods.

Allowing namespaces with access specifiers in class interface would look like this:

class Foo {

namespace {
read_write: [Method_1()];
read_only: [Method_2()];

char data1;
float data2; };

void Method_1();
void Method_2();
void Method_3();

private: // global to class
int x;
int y;

Received on 2022-11-07 20:17:19