What happens when you attempt to compile and run the following code? Choose all that apply.
#include
#include
using namespace std;
int main ()
{
vector
v1.push_back(3);
cout<<v1.capacity()<<" "<< v1.size()<<endl;
return 0;
}
What happens when you attempt to compile and run the following code?
#include
#include
#include
using namespace std;
template
void print(T start, T end) {
while (start != end) {
std::cout << *start << " "; start++;
}
}
int main()
{
int t1[] ={ 1, 7, 8, 4, 5 };
list
int t2[] ={ 3, 2, 6, 9, 0 };
deque
l1.sort();
d1.sort();
l1.merge(d1);
print(l1.begin(), l1.end());
print(d1.begin(), d2.end()); cout<<endl;
return 0;
}
What happens when you attempt to compile and run the following code?
#include
#include
#include
#include
using namespace std;
class B { int val;
public:
B(int v):val(v){} B(){}
int getV() const {return val;} bool operator > (const B & v) const { return val>v.val;} };
ostream & operator <<(ostream & out, const B & v) { out<<v.getV(); return out;}
template
ostream & out;
Out(ostream & o): out(o){}
void operator() (const T & val ) { out<<val<<" "; } };
int main() {
int t[]={8, 10, 5, 1, 4, 6, 2, 7, 9, 3};
deque d1(t, t+10);
sort(d1.begin(), d1.end(), greater());
deque::iterator it = lower_bound(d1.begin(), d1.end(), 4,greater());
for_each(it, d1.end(), Out(cout));cout<<endl;
return 0;
}
Program outputs:
What happens when you attempt to compile and run the following code?
#include
using namespace std;
int main()
{
cout.setf(ios::hex, ios::basefield);
cout<<100<<" ";
cout.unsetf(ios::hex);
cout<<100<<" ";
return 0;
}
Program outputs: