Question: In C++, I am working with a macro where I need to define two variables, the first of which should have the same public / private / protected status as the scope where it is defined, while the other should plainly be private. However, if I just do:

```
#define my_macro(a, b) int a;\
private: int b;

```

then I have permanently changed the scope! This is not good. So I am wondering: is there any way to say: "only *this* variable / member / method / class is private"?

I naively tried doing something like

```
class my_class
{
   public:

   int i;
   private int j;
};

```

But no luck. Is there any way to get what I need?

**EDIT**: I am not sure that the scope in which the macro is defined is public. As I said, "*[...] the first of which should have the same public / private / protected status as the scope where it is defined*", so either public or private or protected, depending on the scope.

Answer: 
No there isn't. There are a few workarounds though:

1. Restrict your variables to a base class from which you inherit, and use your macros there. (Use `protected` rather than `private`).
2. Use an inner `struct` adopting similar techniques to (1).
3. Do the pragmatic thing and have the macro set either the first or final block of members.
4. Don't use macros at all as, generally, they are a pain in the neck.
There is no inbuilt feature in language to do that. There are no `push` and `pop` settings kind of thing as with `warning` and other aspects for pre-processor on some compilers.

The bigger question is *Why*? You declare class' skeleton and change it rarely later. It's not worth the effort. Also, it will make code less readable and complex to maintain.

Don't waste your time on it. I won't be productive or useful.