I'm certainly missing something, but I do not understand why this compiles (with both g++ & clang++):
struct A
{
};
struct B
{
};
int main()
{
A a(B);
}
First of all, B
is a type... not a value. How should I interpret this code?
Because computer can't understand the source code directly. It will understand only object level code. Source codes are human readable format but the system cannot understand it. So, the compiler is intermediate between human readable format and machine-readable format.
Example SentencesHe compiled a book of poems. She compiled a list of names. They took the best submissions and compiled them in a single issue of the magazine. We compiled our findings in the report.
compiler, computer software that translates (compiles) source code written in a high-level language (e.g., C++) into a set of machine-language instructions that can be understood by a digital computer's CPU. Compilers are very large programs, with error-checking and other abilities.
Compile refers to the act of converting programs written in high level programming language, which is understandable and written by humans, into a low level binary language understood only by the computer.
It's interpreted as the declaration of a function named a
, which takes one argument of type B
and returns A
.
It's simply a function declaration declaring a
to be a function returning A
and taking one unnamed parameter of type B
.
It is valid because function declarations as opposed to function definitions are allowed within function definitions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With