Learning C++20: import <iostream>; error?

Viewed 235

I'm starting to learn C++20, my first compilable language...

import <iostream>;

int main()
{
    int answer {42};
    std::cout << "The answer is "
            << answer
            << std::endl;
    return 0;

}

When I try to compile the file above, I get an error message due to the compiler not recognizing the statement import <iostream>;, even though I have the newest version of GCC compiler for Ubuntu 20.04.4 LTS.

1 Answers

C++ 20 is considered a new standard (or maybe the latest standard). So most of the compilers do not have full coverage of everything in C++ 20 and the GCC compiler that you are using does not know what is import <iostream> because it does not have full coverage. What you could do, is to check out this list of compilers supporting C++ 20.

Related