Im implementing a B-tree in C++,I have a stack which saves pairs . my problem is, how i put in this stack because push only accept 1 argument. thanks
Use std::pair provided by the standard library.
You can create them with the function make_pair.
#include <iostream>
#include <stack>
#include <string>
using namespace std;
int main(int argc, char **argv)
{
int myInt = 1;
string myString("stringVal");
stack<pair<string, int> > myStack;
myStack.push(make_pair(myString, myInt));
return 1;
}
#include <utility>
// ...
stack<pair<string,string> > s;
s.push(make_pair("roses", "red"));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With