hi,
i created a function
ostream& operator<<(ostr eam& out, vector<Card>& deck)
{
int i = 0;
for (int s = 1; s <= 4; s++)
{
for (int r = 1; r <= 13; r++, i++)
{
deck[i].setSuit(s);
deck[i].setRank(r);
deck[i].printCard(out) ;
}
out << endl;
system("pause") ;
out << endl;
}
return out;
}
//that will print out the ordered deck of cards, i need to create a
function that will overload ostream operator, and that will print out
the cards in the hand in random order(ranges 5 to 15)...
void fillHand(ostrea m& out, vector<Card>& hand, vector<Card>& deck2)
{
for(unsigned int i = 0; i < hand.size(); i++)
{
int random;
random = randNum(0, 51);
if(deck2[random].isPicked())
{
deck2[random].printCard(out) ;
cout << endl;
int last = hand.size() - 1;
hand.push_back( hand[last]);
for(int i = last; i > deck2[random].isPicked();
i--)
{
hand[last] = hand[last - 1];
}
}
else
{
hand[i] = deck2[random];
deck2[random].setPicked(true );
hand[i].printCard(out) ;
cout << endl;
}
}
}
//this worked, but it's not giving me random cards...pls i need help 1 1565
On 14 Dec 2004 10:21:07 -0800 in comp.lang.c++, "sahm" <ab*******@yaho o.com> wrote, //this worked, but it's not giving me random cards...pls i need help
#include <algorithm>
std::random_shu ffle(deck.begin (), deck.end()); This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Zenon |
last post by:
Folks,
I am having a terrible time overloading operators. I have tried what
I thought was the correct way, I tried the cheating (friend
declarations), all to no avail. Sorry for posting tons of code but I
really need help.
thanks,
Zenon
|
by: Robert Wierschke |
last post by:
Hi
I want to overload the operator<< for a class Vector.
class Vector {
double x;
double y;
double z;
|
by: sahm |
last post by:
i need help to use this function, but use an overloaded operator<<
instead....
ostream operator<<(ostream& out, vector<Card>& deck)
{
int i = 0;
for (int s = 1; s <= 4; s++)
{
for (int r = 1; r <= 13; r++, i++)
{
deck.setSuit(s);
|
by: sahm |
last post by:
hi,
i have to create a program that will print the 52 cards in a deck using
the overloaded ostream operator. it worked fine....then i hve to create
a function that will print the cards in hand in random(5, 10).
//error it shld only have two parameters
ostream& operator<<(ostream& out, vector<Card>& deck2, vector<Card>&
hand)
{
|
by: Banshee |
last post by:
Hi there,
I tried with Visual C++ 6.0 to overloading the ostream operator for an
object. While compiling I receive this error:
Compiling...
main.cpp
C:\\main.cpp(8) : error C2678: binary '<<' : no operator defined which
takes a left-hand operand of type 'class ostream_withassign' (or there is no
acceptable conversion)
| |
by: jois.de.vivre |
last post by:
Hi, I'm having some trouble overloading the << operator. I have the
following, very simple code:
#include <iostream>
using namespace std;
class test
{
private:
int val;
|
by: John |
last post by:
I always understood that in C++, if I said
a + b
a.operator+(b) is called.
Now this makes sense with the operator<< when used in the following way
cout << 100; // converts to cout.operator<<(100);
|
by: brzozo2 |
last post by:
Hello, this program might look abit long, but it's pretty simple and
easy to follow. What it does is read from a file, outputs the contents
to screen, and then writes them to a different file. It uses map<and
heavy overloading.
The problem is, the output file differs from input, and for the love of
me I can't figure out why ;p
#include <iostream>
#include <fstream>
#include <sstream>
|
by: Colonel |
last post by:
It seems that the problems have something to do with the overloading of
istream operator ">>", but I just can't find the exact problem.
// the declaration
friend std::istream & operator>(std::istream & in, const Complex & a);
// the methods correspond to the friend
std::istream & operator>(std::istream & in, const Complex & a)
{
std::cout << "real: ";
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |