Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is the compiler bugging me on this one?

Tags:

People also ask

Why am I getting a compiler error?

A compile error happens when the compiler reports something wrong with your program, and does not produce a machine-language translation. You will get compile errors.

What is a compiler bug?

Compilation error refers to a state when a compiler fails to compile a piece of computer program source code, either due to errors in the code, or, more unusually, due to errors in the compiler itself. A compilation error message often helps programmers debugging the source code.

How do you fix a compilation error?

If the brackets don't all match up, the result is a compile time error. The fix to this compile error is to add a leading round bracket after the println to make the error go away: int x = 10; System.

What error does compiler check?

All syntax errors and some of the semantic errors (the static semantic errors) are detected by the compiler, which generates a message indicating the type of error and the position in the Java source file where the error occurred (notice that the actual error could have occurred before the position signaled by the ...

What does it mean when code is compiling?

Compiling is the transformation from Source Code (human readable) into machine code (computer executable).

Why is cross compiling so hard?

"building a cross-compiler is significantly harder than building a compiler that targets the platform it runs on." The problem exists due to the way libraries are built and accessed. In the normal situation all the libraries are located in a specific spot, and are used by all apps on that system.


(using Visual C++ 2010, compiling in debug with optimizations turned off)

I have the following very simple class:

class exampleClass
{
public:
    exampleClass()
    {
        cout << "in the default ctor" << endl;
    }
private:
    exampleClass (const exampleClass& e)
    {
        cout << "in the copy ctor" << endl;
    }
};

When I try to compile it with the following main:

#include <iostream>
using namespace std;

int main()
{
    exampleClass e1=exampleClass();
    return 0;
}

I get the compilation error:

'exampleClass::exampleClass' : cannot access private
                               member declared in class 'exampleClass'

When I remove the access modifier "private" from the copy ctor, the program compiles and prints only:

in the default ctor

Why is this happening? If the compiler will not invoke the copy ctor anyway, why is it bugging me?

Since some people missed the first line (at least before some edits) i will repeat it:

I compiled in debug with optimizations turned off.