I think im having a major derp moment ( probably from so much studying), but regardless here it goes. Its written terribly, but its more or less so i can understand how the code works/ to study for my programming final, and really has no function whatsoever.
How would i pass a stack into a function?, basically so the function would work?
Code
#include <iostream>
#include <stack>
#include <string>
using namespace std;
void func(string &cards);
int main()
{
stack <string> cards;
cards.push("King of Hearts");
cards.push("King of Clubs");
cards.push("King of Diamonds");
cards.push("King of Spades");
func(cards);
}
void func(string &cards)
{
cout << " This is the amount of cards in this bitch : ";
cout << cards.size();
cout << endl;
}
It's for the proof of concept, i know i can just put the
cards.size();
outside of the function and it will work,but im wondering how to make it work by passing it into a function.
This post was edited by Pino38 on Dec 9 2014 06:15pm