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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:37:11+00:00 2026-05-25T10:37:11+00:00

I have two questions, the second being optional. First, in the program below (a

  • 0

I have two questions, the second being optional.
First, in the program below (a prototype of a simple card program), I am getting the following error:

(29): error C2660: ‘shuffle’ : function does not take 1 arguments
with the following code:

#include "stdafx.h"
#include <iostream>
#include <sstream>
#include <deque>
#include <algorithm>
using namespace std;

deque<int> cardDeck (51);
void flip(); //Prototype flip()
void shuffle(); //Prototype shuffle()

int _tmain(int argc, _TCHAR* argv[])
{
    ostream& operator<<(ostream& os, deque<int> dq); //overload << operator to accept deque 
                                                       //arguments
    for (int a=52; a>0; a--) { //initialize the 52 cards in a deck 
        cardDeck.push_front(a); 
    }
    flip(); //prompt my input to check data
    return 0;
}

void flip() { //flip over card in specified location in the deck
    int input;
    cin >> input;
    cout<<cardDeck[input]<<endl;
    shuffle(cardDeck);
    flip();
}

void shuffle(deque<int> dq) {  //use Fisher-Yates algorithm to efficiently and accurately 
                               //randomize card order
     for(int i=dq.size()-1; i>-1; i--) { 
         int j = rand() % (i + 1);
         if(i != j) {
             swap(dq[j], dq[i]);
         }
     }
}

Why do I receive this error? (I have looked around and attempted to solve it myself)

Secondly, I’m not certain if I’m doing the fisher-yates algorithm properly because c++ documentation isn’t easy to find on it (for the version that utilizes swap();) (Brownie points for answering this or pointing out any horribly awful coding practices, not including the lack of classes)

Thanks in advance!

  • 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-05-25T10:37:12+00:00Added an answer on May 25, 2026 at 10:37 am

    The reason you get that error is because you declare shuffle as a function not taking any arguments.

    void shuffle();
    

    Another note is that you probably want to take a reference to the deque in that function, otherwise you’ll shuffle a local copy and won’t have the desired side effect.

    You probably want it to lok like this:

    void shuffle(deque<int>& dq);
    

    Also, you might want to use iter_swap instead of swap to swap the elements. In a dequeue it probably won’t make a difference, but for list or map it would.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two questions: 1) How can I make an array which points to
I have two questions. Do realloc() and memcpy() copy the entries in an array
I actually have two questions regarding the same problem but I think it is
I have two String.printable mysteries in the one question. First, in Python 2.6: >>>
I have two questions.They both are concerning a void in C++,which I am trying
I have the following two methods on an interface for my service layer: ICollection<T>
I am getting my foot into contracting and have had today my first round
I have a two part question Best-Practice I have an algorithm that performs some
I have two tables (well, two relevant for this question) : Bets (holds the
Actually, this question seems to have two parts: How to implement pattern matching? How

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.