Question: 1
What happens when you attempt to compile and run the following code?
#include
using namespace std;
int main()
{
cout<return 0;
}
Program outputs:
Question: 2
What happens when you attempt to compile and run the following code?
#include
#include
#include
using namespace std;
templatestruct Out {
ostream & out;
Out(ostream & o): out(o){}
void operator()(const T & val ) { out<};
struct Sequence {
int start;
Sequence(int start):start(start){}
int operator()() { return start++; }
};
struct Odd { bool operator()(int v) { return v%2==0; } };
int main() {
vector v1(10);
vector v2(10);
generate(v1.begin(), v1.end(), Sequence(1));
stable_partition(v1.begin(),v1.end(), Odd());
for_each(v1.begin(), v1.end(), Out(cout) );cout<return 0;
}
Program outputs:
Question: 3
What happens when you attempt to compile and run the following code?
#include
using namespace std;
int main()
{
cout<return 0;
}
Program outputs:
Question: 4
What happens when you attempt to compile and run the following code?
#include
#include
#include
using namespace std;
templatestruct Out {
ostream & out;
Out(ostream & o): out(o){}
void operator()(const T & val ) { out<};
struct Sequence {
int start;
Sequence(int start):start(start){}
int operator()() { return start++; }
};
struct Odd { bool operator()(int v) { return v%2==0; } };
int main() {
vector v1(10);
vector v2(10);
generate(v1.begin(), v1.end(), Sequence(1));
stable_partition(v1.begin(),v1.end(), Odd());
for_each(v1.begin(), v1.end(), Out(cout) );cout<return 0;
}
Program outputs:
Question: 5
Which are NOT valid instantiations of priority_queue object:
#include
#include
#include
#include
#include
using namespace std;
int main()
{
deque mydeck;list mylist; vector myvector;
priority_queue first;//line I
priority_queue > second;//line II
priority_queue third(first);//line III
priority_queue > fourth(third);//line IV
priority_queue > fifth(myvector.begin(), myvector.end());//line V
return 0;
}