Why is the syntax the way it is for implementing classes in c++?
<p>I tend to write a class declaration in a source file and then decide I want to export it in a header. But this always means that I have to split it up and edit almost every function so that the class is declared in the header, and I have to put the functions individually in the <code>cpp</code> file. </p>

<p>Why is it that I cannot leave the <code>class A {</code> in the source file so I can avoid adding <code>A::</code> at every function? The compiler just assumes it's a redefinition of <code>A</code>. What is the reason that the compiler doesn't simply acknowledge that I am describing the same <code>A</code>?</p>

<p>Also, partly related: Is there a way for me to hide the private variables of a class in the source file rather than putting it in the header? The header is used to export functionality of a class to other parts of a program, to which I do not need to reveal my private members. Yet I don't believe I can declare them in the implementation <code>cpp</code> because I can't redefine the class there, I can only implement functions in there. </p>
