I am stuck with 2 errors.....i have been trying for really long time to fix them

This is a discussion on I am stuck with 2 errors.....i have been trying for really long time to fix them within the C++ Programming forums, part of the General Programming Boards category; Code: #ifndef __DECK_H__ #define __DECK_H__ //============================================================================= // // File : Deck.h //============================================================================= // Author : // Date : Tuesday, June ...

  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    33

    I am stuck with 2 errors.....i have been trying for really long time to fix them

    Code:
    #ifndef __DECK_H__
    #define __DECK_H__
    
    
    //=============================================================================
    //
    // File : Deck.h
    //=============================================================================
    // Author     :   
    // Date       :   Tuesday, June 28, 2011 9:42 AM
    // Summary    :   
    //
    // Description:   
    //
    // Revisions  :   
    //
    //=============================================================================
    //  SYSTEM INCLUDES
    
    #include <iostream>
    #include <stdlib.h>
    #include <time.h>
    
    //  PROJECT INCLUDES
    
    //  LOCAL INCLUDES
    #include "Card.h"
    
    //  USING STATEMENTS
    
    using std::cout;
    using std::cin;
    using std::endl;
    
    //  FORWARD REFERENCES
    
    //  CONSTANTS
    
    //  TYPEDEFS
    
    //  FUNCTION PROTOTYPES
    
    //  STRUCT DECLARATIONS
    
    //  CLASS DECLARATIONS
    #pragma region CLASS_DECLARATION Deck
    
    // class       Deck
    // Author   :  
    // Date     :  Tuesday, June 28, 2011 9:44 AM
    // Summary  :  
    //        
    //
    // Invariants 
    //  
    // Revisions:  
    //        
    class Deck
    {
    
    public:
    
    	// CONSTRUCTION 
    
    	// Default constructor.
    	// Summary  :  
    	Deck(  );
    
    	// Copy Constructor.
    	// Summary  :  
    	Deck( const Deck& from );
    
    	// Destructor.
    	// Summary  :  
    	~Deck( );
    
    	void shuffle(void);
    
    	void printDeck(void);
    
    	// METHODS 
    
    
    protected: 
    
    
    private: 
    
    
    	// METHODS  
    
    
    	// ATTRIBUTES 
    	Card mDeck[52];
    
    
    }; 
    
    // NON-MEMBER FUNCTIONS  
    
    
    #pragma endregion  
    
    
    
    
    #endif //__DECK_H__
    Code:
    #include   "Deck.h" 
    
    Deck::Deck()
    {
    
    	string suits[4] = {"Spades" , "Hearts" , "Clubs" , "Diamonds"};
    	string pips = "234567890JQKA";
    	for(int i= 0; i < 52; ++i)
    	{
    		mDeck[i] = Card(suits[i/13],pips[i%13+2]);
    	}
    }
    Deck::~Deck()
    {
    }
    
    void Deck::printDeck(void)
    {
    	for( int i = 0; i < 52; ++i)
    	{
    		mDeck[i].printCard();
    		cout<<endl;
    	}
    }
    void Deck::shuffle(void)
    {
    	srand ( time(NULL) );
    
    	for (int i = 0; i <1024; ++i)
    	{
    		int index1, index2;
    		index1 = rand() %52;
    		index1 = rand() %52;
    
    		Card tmp = mDeck[index1];
    		mDeck[index1] = mDeck[index2];
    		mDeck[index2] = tmp;
    	}
    }


    The errors are:

    Code:
    Error	1	error C2661: 'Card::Card' : no overloaded function takes 2 arguments	
    
    Error	3	fatal error LNK1104: cannot open file '..\debug\cards.lib'	TestCards

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    You have this line
    Code:
    mDeck[i] = Card(suits[i/13],pips[i%13+2])
    The right-hand side is a constructor for a Card object, and you are giving it two parameters. The error message says "you didn't write a function that takes two arguments". So either write such a function, or figure out what function you meant to call instead.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. completely stuck understanding how to use time.h
    By pastitprogram in forum C++ Programming
    Replies: 11
    Last Post: 04-04-2008, 11:11 AM
  2. I forget c for a long time.
    By zhshqzyc in forum C++ Programming
    Replies: 7
    Last Post: 10-22-2007, 03:59 AM
  3. woh~ Not coming for such long time
    By black in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 09-01-2002, 08:10 PM
  4. stuck on time!!!!
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 04-19-2002, 08:51 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21