Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9274875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T16:27:21+00:00 2026-06-18T16:27:21+00:00

i declared a test variable of auto type but now i don’t know how

  • 0

i declared a test variable of auto type but now i don’t know how to access it. I know how to make this prograame work without auto but here i want to know how to access that auto variable.

int main() {
auto test = {'1','S'};
std::cout<<test; //error no match for operator... i tried using *test or *test[0] but no solution.  
cin.get();
return 0;
}

Compiler log :

Compiler: mingw
Executing  g++.exe...
g++.exe "C:\Users\Arpit\Desktop\delete.cpp" -o "C:\Users\Arpit\Desktop\delete.exe"   -std=c++11   
C:\Users\Arpit\Desktop\delete.cpp: In function 'int main()':
C:\Users\Arpit\Desktop\delete.cpp:5:12: error: cannot bind 'std::ostream {aka std::basic_ostream<char>}' lvalue to 'std::basic_ostream<char>&&'
In file included from c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.7.1/include/c++/iostream:40:0,

                 from C:\Users\Arpit\Desktop\delete.cpp:1:
c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.7.1/include/c++/ostream:600:5: error:   initializing argument 1 of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&&, const _Tp&) [with _CharT = char; _Traits = std::char_traits<char>; _Tp = std::initializer_list<char>]'

Execution terminated

How to print test?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T16:27:22+00:00Added an answer on June 18, 2026 at 4:27 pm

    You got this error since auto variable = { ... } declares an std::initializer_list, which do not have overloaded operator<< for std::ostream. You can use, for example, range-based for to get access to values from your list.

    int main()
    {
        auto test = {'1','S'};
        for(const auto& elem: test)
            std::cout << elem << ' ';
        std::cout << std::endl;
    
        return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a variable declared at the top of my function as this.current_test =
Sometimes I need to test which class has declared some variable(s), is there another
I have declared a variable in my .xsl file. Now I want to update
Is it possible to access value of a global variable declared, in another perl
How can I test wether a variable has been declared or assigned (i.e. check
I've declared a String variable test with hi. every time I click on Button1,
Let's say I declare a variable: String a = test; And I want to
I declared a button: <button id=create type=button>add div</button> and I want to add a
I declared a global shift operator but for some reason the compiler cannot deduct
I get the error : A local variable named 's' cannot be declared in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.