Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Error Using << Operator with std::cout in Visual Studio 2022 on Windows 11“ #132

Open
12shuaibi opened this issue Oct 17, 2024 · 0 comments

Comments

@12shuaibi
Copy link

Issue Description
I am encountering an issue when trying to use std::cout in various C++ programs compiled using Visual Studio 2022 on Windows 11. Whenever I attempt to use the << operator with std::cout to print a variable, I get the following errors during compilation:

Error (active) E0349: No operator "<<" matches these operands
Error C2678: Binary "<<" : no operator found which takes a left-hand operand of type "std::basic_ostream<char,std::char_traits>" (or there is no acceptable conversion)

This error appears in multiple programs, not just when using the Big type from the MIRACL library.

Example Code
Here is one of the example programs where the issue occurs. The code is meant to calculate the factorial of a number using MIRACL's Big type:

extern "C"
{
#include <miracl.h>
}

#include <big.h>
#include

using namespace std;

Miracl precision(500, 10); // This makes sure that MIRACL is initialised before main() is called

int main()
{
Big nf = 1; // declare "Big" variable nf
int n;
cout << "factorial program\n";
cout << "input number n= \n";
cin >> n;

while (n > 1)
    nf *= (n--); // nf=n!=n*(n-1)*(n-2)*....3*2*1

cout << "n!= \n" << nf << "\n"; // This line causes the error

}

However, I've also encountered the same error in simpler programs that don't involve the Big type. It appears that Visual Studio 2022 is struggling to find a valid overload for the << operator in these cases.

System Information
Operating System: Windows 11
Development Environment: Visual Studio 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant