What happens when you attempt to compile and run the following code?
#include
#include
#include
using namespace std;
template
ostream & out;
Out(ostream & o): out(o){}
void operator()(const T & val ) {
out<<val<<" ";
}
};
struct Sequence {
int start;
Sequence(int start):start(start){}
int operator()() { return start++; } };
int main() {
vector
vector
generate(v1.begin(), v1.end(), Sequence(1));
random(v1.begin(),v1.end());
for_each(v1.begin(), v1.end(), Out
return 0;
}
Program outputs:
What will be output of the program when you attempt to compile and run the following code?
#include
#include
#include
#include
using namespace std;
int main(){
int second[] ={ 3, 4, 2, 1, 6, 5, 7, 9, 8, 0 };
string first[] = {"three", "four", "two", "one", "six","five", "seven", "nine","eight","zero"};
multimap
for(int i=0; i<10; i++) {
m.insert(pair
}
m[0]="ten";
m.insert(pair
for(multimap
cout<<i?>second<<" ";
}
return 0;
}
What happens when you attempt to compile and run the following code?
#include
#include
using namespace std;
class A
{
int a,b;
public:
A(const A & c) { a = c.a; }
A():a(0),b(0){}
void setA(int a) {this?>a = a;} void setB(int b) {this?>b = b;}
int getA() {return a;} int getB() {return b;}
};
int main ()
{
vectorv;
A a;
a.setA(10); a.setB(11);
v.push_back(a);
cout<<v[0].getB()<<" "<<v[0].getA()<<endl;
return 0;
}
What will happen when you attempt to compile and run the code below, assuming that you enter the following sequence: one two three
#include
#include
using namespace std;
int main ()
{
string a;
cin.getline(a);
cout<<a<<endl;
return 0;
}
Program will output: