Error messages C3861 and C2084 in user-defined headers

This is a discussion on Error messages C3861 and C2084 in user-defined headers within the C++ Programming forums, part of the General Programming Boards category; Hi, I have looked over my code and the message boards and am having problems resolving error messages in my ...

  1. #1
    Registered User
    Join Date
    Sep 2006
    Posts
    27

    Error messages C3861 and C2084 in user-defined headers

    Hi,

    I have looked over my code and the message boards and am having problems resolving error messages in my user-defined header files "randcard.h" and "dealer.h".


    Code for randcard.h:
    Code:
    # include <iostream>
    using namespace std;
    
    void randcard(int[4][13], int[4][13], int [52], int&, int&, int&, string&, string&);
    
    void randcard(int deckdeck[4][13], int cardcard[4][13], int cardsplayed[52], int& cardd, int& suitrand, int& cardrand, string& suitname, string& cardname)
    {
    	int slow = 0, shigh = 4;
    	int clow = 0, chigh = 13;
    	char cardgood = 'n';
    	char dupcard;
    	int ncard = 1;
    
    	for (int k = 0; k <= 3; k++)
    	{
    		for (int l = 0; l <= 12; l++)
    		{cardcard[k][l]= ncard;
    		//cout << "Cardcard[" << k << "][" << l << "]:" << cardcard[k][l] << endl;
    		ncard++;
    		}}
    
    
    	do
    	{
    	suitrand = slow + (double)rand()/(double) RAND_MAX*(shigh - slow);
    	cardrand = clow + (double)rand()/(double) RAND_MAX*(chigh - clow);
    
    	//cout << "suit: " << suitrand << "  card: " << cardrand << "  cardcard: " << cardcard[suitrand][cardrand]<< endl;
    
    		dupcard = 'n';
    
    		//cout << "suit: ";
    		//cin >> suitrand;
    
    		//cout << "card: ";
    		//cin >> cardrand;
    
    	for (int i = 0; i < 52; i++)
    	{
    		if (cardsplayed[i] == cardcard[suitrand][cardrand])
    			dupcard = 'y';
    		//if (dupcard == 'y') cout << "DUPLICATE CARD" << endl;
    	}
    
    		if (dupcard == 'n')
    		{cardsplayed[(cardd)] = cardcard[suitrand][cardrand];
    
    		//cout << "in cardcheck, cardd = " << cardd << endl;
    		//cout << "in cardcheck, cardsplayed " << cardsplayed[cardd] << endl;
    
    		cardd = cardd +1;
    
    		//cout << "Cardd: " << cardd << endl;
    
    		cardgood = 'y';
    
    		//cout << "in cardcheck, cardgood = " << cardgood << endl;
    		}
    	}while (cardgood == 'n');
    
    	//cout << "suitrand: " << suitrand << endl;
    	//cout << "cardrand: " << cardrand << endl;
    
    	//Naming suits.
    	
    	switch(suitrand){
    		case 0: 
    			suitname = "clubs";
    			break;
    		case 1: 
    			suitname = "diamonds";
    			break;
    		case 2: 
    			suitname = "hearts";
    			break;
    		case 3: 
    			suitname = "spades";
    			break;}
    	
    	//Naming Cards.
    
    	switch(cardrand){
    		case 0: 
    			cardname = "two";
    			break;
    		case 1: 
    			cardname = "three";
    			break;
    		case 2: 
    			cardname = "four";
    			break;
    		case 3: 
    			cardname = "five";
    			break;
    		case 4: 
    			cardname = "six";
    			break;
    		case 5: 
    			cardname = "seven";
    			break;
    		case 6: 
    			cardname = "eight";
    			break;
    		case 7: 
    			cardname = "nine";
    			break;
    		case 8: 
    			cardname = "ten";
    			break;
    		case 9: 
    			cardname = "jack";
    			break;
    		case 10: 
    			cardname = "queen";
    			break;
    		case 11: 
    			cardname = "king";
    			break;
    		case 12: 
    			cardname = "ace";
    			break;}
    }
    For randcard.h, I get the error "c:\documents and settings\owner\my documents\randcard.h(7) : error C2084: function 'void randcard(int [][13],int [][13],int [],int &,int &,int &,std::string &,std::string &)' already has a body". This is followed by the message " c:\documents and settings\owner\my documents\randcard.h(4) : see previous definition of 'randcard'".


    Code for "dealer.h":
    Code:
    # include <iostream>
    # include "randcard.h"
    
    using namespace std;
    
    void dealer (int[4][13], int[4][13], int [52], int, int&, int, string, string, string, string);
    
    void dealer(int deckdeck[4][13], int cardcard[4][13], int playedcards[52], int carddr, int& dealertot, int dace, string suitfirst, string cardfirst, string suittextt, string cardtextt)
    {
    	int suitnum;
    	int cardnum;
    	string suittext, cardtext;
    	int deck[4][13];
    	int card[4][13];
    	int cardspl[52];
    	int cardd =0;
    	
    
    	//Dealer's two cards are shown
    
    	cout << "The dealer's hand:    " << cardfirst << " of " << suitfirst << endl;
    	cout << "                  " << cardtextt << " of " << suittextt << endl;
    	
    	if (dealertot == 21)
    		cout << endl << "Dealer blackJack" << endl;
    
    	//Dealer's hand is played, hits on anything less than a 17 as per casino rules
    
    	while (dealertot < 17)
    	{
    		randcard(deck, card, cardspl, cardd,  suitnum, cardnum, suittext, cardtext);
    		cout << "                  " << cardtext << " of " << suittext << endl;
    		dealertot = dealertot + deckdeck[suitnum][cardnum];
    
    		if (cardnum == 12)
    			dace = dace + 1;
    
    		if (dealertot > 21 && dace > 0)
    		{
    			dealertot = dealertot - 10;
    			dace = dace - 1;
    		}
    	}
    	cout << endl << "Dealer's total:   " << dealertot << endl << endl;
    }
    For "dealer.h", I get the error message "c:\documents and settings\owner\my documents\dealer.h(31) : error C3861: 'randcard': identifier not found".

    How can I resolve these errors?

    Thanks,
    J

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    7,317
    You need to add header include guards to your header file(s).

  3. #3
    Registered User
    Join Date
    Sep 2006
    Posts
    27
    Thank you. That fixed the problem.

    J

Popular pages Recent additions subscribe to a feed

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