Here's some code for example  class A {   int i; }  void main() {   A a; }   Is there any possible (probably hackish) way to access a::i in main?  Edit: a::i is supposed to stay private.
Disclaimer Yes, I am fully aware that what I am asking about is totally stupid and that anyone who would wish to try such a thing in production code should be fired and/or shot.  I'm mainly looking to see if can be done. Now that that's out of the way, is there any way to access private class members in C++ from outside the class?  For example, is there any way to do this with pointer offsets? (Naive and otherwise non-production-ready techniques welcome) Update As noted in the comments, I asked this question because I wanted to write a blog post on over-encapsulation (and how it affects TDD).  I wanted to see if there was a way to say &quot;using private variables isn't a 100% reliable way to enforce encapsulation, even in C++.&quot;  At the end, I decided to focus more on how to solve the problem rather than why it's a problem, so I didn't feature some of the stuff brought up here as prominently as I had planned, but I still left a link. At any rate, if anyone's interested in how it came out, here it is:   (I suggest reading it before you decide that I'm crazy).
On the first puzzle of the quest Under Saarthal (the one with the six pillars), I enter the correct combination, but the door still doesn't open, and arrows are still shot at me. I've reloaded the game a couple hundred times, I've left the room, and it still doesn't work. What do I do? How to upgrade Git on Ubuntu Hardy? When I run:  tex algorithms.dtx   for example, I get this message.    ! Undefined control sequence. l.34 \documentclass                    {ltxdoc} ?   Help? Remove all content using pure JS How to get Url Hash (#) from server side Book about mages who can harvest magical energy from the environment Proof that the One-Dimensional Simple Harmonic Oscillator is Non-Degenerate? jsp:useBean scope Is it worth it to buy an FD-EOS adapter, or is it better to exchange a misbought lens? I recently bought a manual-focus (since manual doesn't bother me) . However, I didn't notice at the time of purchase that it was an FD lens. (I'm a hobbyist; I didn't know Canon had actually changed lens mounts at some point.)  On the one hand, I kind of want to experiment with this guy. And quality FD lenses are relatively cheap on the used market, so if the adapters were worth it, I could probably get more (and more varied) glass. On the other hand, everything I read about the FD-EOS adapters is highly contradictory. As in, some people swear by them, and others think they're outright tripe.  I am still within the exchange period, and can easily exchange this lens for this  that I'd been tossing up about buying anyway, as they are the same price.  Which would be the wiser choice? This is a question I've been asked several times by students and I tend to have a hard time phrasing it in terms they can understand. This is a natural question to ask and it is not usually well covered in textbooks, so I would like to know of various perspectives and explanations that I can use when teaching.  The question comes up naturally in what is usually students' second course in quantum physics / quantum mechanics. At that stage one is fairly comfortable with the concept of wavefunctions and with the Schrödinger equation, and has had some limited exposure to operators. One common case, for example, is to explain that some operators commute and that this means the corresponding observables are 'compatible' and that there exists a mutual eigenbasis; the commutation relation is usually expressed as $[A,B]=0$ but no more is said about that object.  This naturally leaves students wondering     what is, exactly, the physical significance of the object $[A,B]$ itself?   and this is not an easy question. I would like answers to address this directly, ideally at a variety of levels of abstraction and required background. Note also that I'm much more interested in the object $[A,B]$ itself than what the consequences and interpretations are when it is zero, as those are far easier and explored in much more depth in most resources.    One reason this is a hard question (and that commutators are such confusing objects for students) is that they serve a variety of purposes, with only thin connecting threads between them (at least as seen from the bottom-up perspective).   Commutation relations are usually expressed in the form $[A,B]=0$ even though, a priori, there appears to be little motivation for the introduction of such terminology. A lot of stock is placed behind the canonical commutation relation $[x,p]=i \hbar$, though it is not always clear what it means.  (In my view, the fundamental principle that this encodes is essentially de Broglie's relation $\lambda=h/p$; this is made rigorous by the  but that's quite a bit to expect a student to grasp at a first go.) From this there is a natural extension to the Heisenberg Uncertainty Principle, which in its general form includes a commutator (and an anticommutator, to make things worse). Canonically-conjugate pairs of observables are often introduced, and this is often aided by observations on commutators. (On the other hand, the energy-time and angle-angular momentum conjugacy relations cannot be expressed in terms of commutators, making things even fuzzier.) Commutators are used very frequently, for example, when studying the angular momentum algebra of quantum mechanics. It is clear they play a big role in encoding symmetries in quantum mechanics but it is hardly made clear how and why, and particularly why the combination $AB-BA$ should be important for symmetry considerations.  This becomes even more important in more rigorous treatments of quantum mechanics, where the specifics of the Hilbert space become less important and the algebra of observable operators takes centre stage. The commutator is the central operation of that algebra, but again it's not very clear why that combination should be special. An analogy is occasionally made to the Poisson brackets of hamiltonian mechanics, but this hardly helps - Poisson brackets are equally mysterious. This also ties the commutator in with time evolution, both on the classical side and via the Heisenberg equation of motion.   I can't think of any more at the moment but they are a huge number of opposing directions which can make everything very confusing, and there is rarely a uniting thread. So: what are commutators, exactly, and why are they so important? I am trying to sniff on a custom SPI-like bus protocol, which uses a unified bidirectional data line instead of separate MISO/MOSI. To make sense of the communication, I need to split it up into unidirectional lines before feeding them to my logic analyzer. Otherwise I wouldn't be able to see which device is responsible for which part of the signal. Since my devices won't talk to each other unless the protocol is carried out correctly, it's obvious that the bus splitting device has to be transparent to the actual agents communicating.  I tried to construct a bus splitting device, but failed as described . Since this question was maybe too specific and has not been answered, I want to ask more generally: Is there a bidirectional bus splitter that is able to split  into four wire SPI? Where could I buy such a device? (This seems similar to  question, only that I'm not talking about two really different protocols, so the answer does not apply). In principle only getting one direction would also suffice, since I could just subtract it from the full signal in order to retrieve the other half. And I'm also only interested in the master side of the communication.    The  seems to be a good candidate. Although it's advertised for use with I2C, it seems to be agnostic to the actual protocol on the lines. (As it does not even differentiate between DATA and CLOCK line for I2C.)     Splits I2C-bus signal into pairs of forward/reverse Tx/Rx, Ty/Ry signals for interface with opto-electrical isolators and similar devices that need unidirectional input and output signal paths.   As my devices operate on SPI mode 3 (polarity 1, idling on HIGH), the implementation of the receive pin should work:        sense the voltage state of the I2C-bus pin Sx (or Sy) and transmit this state to the pinTx (Ty respectively), and   sense the state of the pin Rx (Ry) and pull the I2C-bus pin LOW whenever Rx (Ry) is LOW.      But I am still puzzled on how this would actually work in sniffing this bidirectional bus. I could connect one device with the I2C line and grab its MOSI at Tx and MISO at Rx, but I would eventually have to connect both lines before feeding it to the other device, therefore making it impossible to separate the signals at my logic analyzer again. How can I connect the Tx/Rx for the slave while still being able to read them separately with a third device?  Edit: I now think this is actually not helping at all, since it leaves me with the same splitting issue as with out the device. I already have separate master and slave lines, I just don't know how to join them while still retrieving the separate directions.    I also stumbled upon the . It seems like this is a device designed for sniffing on buses, but I don't think it can help me in my case. Is there a mode where I can use it as a bridge on a bidirectional line and grab unidirectional signals off of it simultaneously?    Edit: I found this  which seems related to the issue. This does supposedly split the bidirectional line to feed it to two unidirectional isolators. The question is: Does this work for my setup? It describes the I2C lines being open-drain, whereas my lines are open-collector and also I'm not entirely sure if I could just leave out the isolator part and grab the signals from the lines or if these would have to be also hooked up to some transistor or be pulled high. I'm looking into a restful design and would like to use the HTTP methods (POST, GET, ...) and HTTP headers as much as possible. I already found out that the HTTP methods PUT and DELETE are not supported from the browser.  Now I'm looking to get different representations of the same resource and would like to do this by changing the Accept header of the request. Depending on this Accept header, the server can serve a different view on the same resource.  Problem is that I didn't find a way to tell my browser to change this header.   The &lt;a..&gt; tag has a , that can have a mime type, looked like a good candidate but the header was still the browser default (in Firefox it can be changed in about:config with the network.http.accept.default key). I have some music discs, but every time I put it in a jukebox I can't hear it. It says it's playing, my friend (on PS4) says he can hear it, but I don't. All other audio is fine, I can hear the game audio fine, even if I have a world that's only me: it still doesn't produce jukebox sounds. It visually shows that it's playing (the notes come out of the jukebox) but there is no music. I play on Pocket Edition. Can someone help me resolve this issue? I read somewhere that according to relativity, it is possible - involving black holes and other stuff - to jump into the past. Is it possible for anything to go back in time either continuously or by jumping? Why does my object not show up? This is meant to solve this problem once and for all. What is every reason an object isn't showing up in a render or viewport in when using the cycles render engine? jquery stop child triggering parent event Limit of the sequence $a_n=\sqrt[n+1]{(n+1)!}-\sqrt[n]{n!}$ How long are the life phases of a dragon? How do I return a longitude and latitude from Google Maps JavaScript geocoder? "How" vs. "that" in "You know how we have pizza on Thursdays, right?" From time to time I hear sentences like this:      You know how we have pizza on Thursdays, right?   Here, how doesn't mean exactly how those guys eat pizza, it is something like "that" in this context.   So what is the difference between using how, that or just skipping the conjunction?