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 9006287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:22:12+00:00 2026-06-16T01:22:12+00:00

Hey im trying to print out my multimap values but im getting an error

  • 0

Hey im trying to print out my multimap values but im getting an error on this

for ( multimap< int, Questions, less< int > >::iterator iterator = question_map.begin();
      iterator != question_map.end(); ++iterator )
      cout << iterator->first << '\t' << iterator->second << '\n';

The error states:

Error   1   error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'Questions' (or there is no acceptable conversion)    c:\users\conor\documents\college\dkit - year 2 - repeat\dkit - year 2 - semester 1 - repeat\games programming\millionaire\millionaire\questions.cpp 31  1   Millionaire

Here is the rest of my code:

Questions.h
#ifndef QUESTIONS_H
#define QUESTIONS_H
#include <string>
#include <algorithm>
#include <map>
#include <iostream>
using namespace std;

class Questions
{
public:
    Questions();
    Questions(string question,string correctAnswer, string wrongAnswer1,string wrongAnswer2,string wrongAnswer3);
    //void shuffle(string *array, int n);
    //string getQuestion();
    //string getCorrectAnswer();
    //string getAnswers();
    //bool checkAnswer(string answer);
    void questionStore();
    //void addQuestion(int level, Questions question);
    //Questions printQuestion(int level);
    //ostream& operator<<(const ostream& out, const Questions& q);


private:
    string question;
    string correctAnswer;
    string wrongAnswer1;
    string wrongAnswer2;
    string wrongAnswer3;
    multimap<int,Questions> question_map;
};

#endif

Questions.cpp

#include <iostream>
#include "Questions.h"
using namespace std;
Questions :: Questions()
{

}
Questions :: Questions(string question,string correctAnswer, string wrongAnswer1,string wrongAnswer2,string wrongAnswer3)
{
}


void Questions :: questionStore()
{
Questions q1 = Questions("Whats the oldest known city in the world?", "Sparta" , "Tripoli" , "Rome", "Demascus");
Questions q2 = Questions("What sport in the olympics are beards dissallowed?", "Judo", "Table Tennis" , "Volleyball", "Boxing");
Questions q3 = Questions("What does an entomologist study?", "People" , "Rocks" , "Plants", "Insects");
//string q4 = ("Where would a cowboy wear his chaps?", "Hat" , "Feet" , "Arms", "Legs");
//tring q5 = ("which of these zodiac signs is represented as an animal that does not grow horns?", "Aries" , "Tauris" , "Capricorn", "Aquarius");
//string q6 = ("Former Prime Minister Tony Blair was born in which country?", "Northern Ireland" , "Wales" , "England", "Scotland");
//string q7 = ("Duffle coats are named after a town in which country?", "Austria" , "Holland" , "Germany", "Belgium");
//string q8 = ("The young of which creature is known as a squab?", "Horse" , "Squid" , "Octopus", "Pigeon");
//string q9 = ("The main character in the 2000 movie ""Gladiator"" fights what animal in the arena?", "Panther" , "Leopard" , "Lion", "Tiger");

question_map.insert(pair<int,Questions>(1,q1));
question_map.insert(pair<int,Questions>(1,q2));
question_map.insert(pair<int,Questions>(1,q3));

for ( multimap< int, Questions, less< int > >::iterator iterator = question_map.begin();
      iterator != question_map.end(); ++iterator )
      cout << iterator->first << '\t' << iterator->second << '\n';
}
  • 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-16T01:22:13+00:00Added an answer on June 16, 2026 at 1:22 am

    Add operator<< as friend of Qeustions, so it can access private member of Question class.

    In Questions.h, declare operator<< as a non-member function

    class Questions
    {
    public:
        Questions();
        Questions(string question,string correctAnswer, string wrongAnswer1,string wrongAnswer2,string wrongAnswer3);
        void questionStore();
    private:
        string question;
        string correctAnswer;
        string wrongAnswer1;
        string wrongAnswer2;
        string wrongAnswer3;
        multimap<int,Questions> question_map;
    
        friend std::ostream& operator<<(std::ostream& stream, Questions const& q);
    };
    
    std::ostream& operator<<(std::ostream& stream, Questions const& q);
    

    in Questions.cpp, define operator<< function

    std::ostream& operator<<(std::ostream& stream, Questions const& q)
    {
        stream << q.question << " " << q.correctAnswer;  
        return stream;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey im trying to print out from a multimap. My multimap is: multimap<int,Questions*> map;
hey I'm trying to figure out what this element is in an app I
Hey I'm having a problem trying to figure this out: Lets start out with
Hey all! Having a little trouble with my stack. Im trying to print each
Hey im trying to add countdown timers to an arraylist but it is crashing.
Hey in trying to submit my app to iTunes. It passes the validation, but
Hey I'm trying to figure out how to convert a statement that works in
Hey again guys. So, I'm trying to find out how to select every field
Hey all. Trying to get a little more efficient with lists in Python but
Hey everyone, So, I'm currently trying the implement the APNG Specification , but am

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.