C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 20th, 2012, 03:55 PM
eats_food_a_lot eats_food_a_lot is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2012
Posts: 6 eats_food_a_lot User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 13 m 11 sec
Reputation Power: 0
Why does this virtual function not work?

I am making a BlackJack card game and I am trying to get the CardFlow base class to give the inherited class, Player1, the current card and it has an error of " Expression: vector iterator + offset out of range ", when I run the program and ask for a hit. Why is this not working and what does this error mean? Here are parts of the code I am having trouble with. Any help would be appreciated.




Code:
" main_program.cpp "
Player1 ph;
	
	CardFlow pCard;
	while(cardHit){ 
	                                // Loop for player to get card hits
	cardHit = ph.getHit(cardHit);
	if(cardHit == true){
		dCardHit = false;
	
	int pcur = ph.getCurrCard();
	int pCur = pcur;
	Player1 playersCount(pCur);
	int playCount = ph.getPcount();
	cout << pcur << "  "  << playCount << endl;
	}
	
	else dCardHit = true;
	

	} // End while cardHIt

" Player1.cpp" - Inherited class

int Player1::getCurrCard() 
	
{
	return CardFlow::getCurrCard();
}

"CardFlow.cpp" - Base class
int CardFlow::getCurrCard() 
{
	for(int i = 0; i <= 51; i++){
		random_shuffle (deck.begin(), deck.end());
		sort (deck.begin(), deck.begin()+25);
		random_shuffle (deck.begin(), deck.end());
		sort (deck.begin(), deck.begin()+12);
		random_shuffle (deck.begin(), deck.end());
		currentCard = deck[i];
	
	}

	return currentCard;
}

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > Why does this virtual function not work?

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap