81. What does the size of the vector refers to in c++?
82. What will be the output of the following C++ code?
#include <iostream>
#include <array>
using namespace std;
int main(int argc, char const *argv[])
{
array<int, 10> arr1 = {1,2,3,4,5};
array<int, 5> arr2 = {6,7,8,9,10};
arr1.swap(arr2);
for(int i=0;i<5;i++)
cout<<arr1[i]<<" ";
cout<<endl;
for(int i=0;i<5;i++)
cout<<arr2[i]<<" ";
cout<<endl;
return 0;
}
#include <iostream>
#include <array>
using namespace std;
int main(int argc, char const *argv[])
{
array<int, 10> arr1 = {1,2,3,4,5};
array<int, 5> arr2 = {6,7,8,9,10};
arr1.swap(arr2);
for(int i=0;i<5;i++)
cout<<arr1[i]<<" ";
cout<<endl;
for(int i=0;i<5;i++)
cout<<arr2[i]<<" ";
cout<<endl;
return 0;
}83. Which function is used to check whether a character is hexadecimal?
84. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
class vec
{
public:
vec(float f1, float f2)
{
x = f1;
y = f2;
}
vec()
{
}
float x;
float y;
};
vec addvectors(vec v1, vec v2);
int main()
{
vec v1(3, 6);
vec v2(2, -2);
vec v3 = addvectors(v1, v2);
cout << v3.x << ", " << v3.y << endl;
}
vec addvectors(vec v1, vec v2)
{
vec result;
result.x = v1.x + v2.x;
result.y = v1.y + v2.y;
return result;
};
#include <iostream>
using namespace std;
class vec
{
public:
vec(float f1, float f2)
{
x = f1;
y = f2;
}
vec()
{
}
float x;
float y;
};
vec addvectors(vec v1, vec v2);
int main()
{
vec v1(3, 6);
vec v2(2, -2);
vec v3 = addvectors(v1, v2);
cout << v3.x << ", " << v3.y << endl;
}
vec addvectors(vec v1, vec v2)
{
vec result;
result.x = v1.x + v2.x;
result.y = v1.y + v2.y;
return result;
};85. The destination statement for the goto label is identified by what label?
86. Given below classes which of the following are the possible row entries in vtable of D2 class?
class Base
{
public:
virtual void function1() {};
virtual void function2() {};
};
class D1: public Base
{
public:
virtual void function1() {};
};
class D2: public Base
{
public:
virtual void function2() {};
};
class Base
{
public:
virtual void function1() {};
virtual void function2() {};
};
class D1: public Base
{
public:
virtual void function1() {};
};
class D2: public Base
{
public:
virtual void function2() {};
};87. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main ()
{
char str[] = "Steve jobs";
int val = 65;
char ch = 'A';
cout.width (5);
cout << right;
cout << val << endl;
return 0;
}
#include <iostream>
using namespace std;
int main ()
{
char str[] = "Steve jobs";
int val = 65;
char ch = 'A';
cout.width (5);
cout << right;
cout << val << endl;
return 0;
}88. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
template <class T>
T max (T &a, T &b)
{
cout << "Template Called ";
return (a > b)? a : b;
}
template <>
int max <int> (int &a, int &b)
{
cout << "Called ";
return (a > b)? a : b;
}
int main ()
{
int a = 10, b = 20;
cout << max <int> (a, b);
}
#include <iostream>
using namespace std;
template <class T>
T max (T &a, T &b)
{
cout << "Template Called ";
return (a > b)? a : b;
}
template <>
int max <int> (int &a, int &b)
{
cout << "Called ";
return (a > b)? a : b;
}
int main ()
{
int a = 10, b = 20;
cout << max <int> (a, b);
}89. What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
class A
{
int a;
public:
virtual void func() = 0;
};
class B: public A
{
public:
void func(){
cout<<"Class B"<<endl;
}
};
int main(int argc, char const *argv[])
{
A a;
a.func();
return 0;
}
#include <iostream>
#include <string>
using namespace std;
class A
{
int a;
public:
virtual void func() = 0;
};
class B: public A
{
public:
void func(){
cout<<"Class B"<<endl;
}
};
int main(int argc, char const *argv[])
{
A a;
a.func();
return 0;
}90. To use command line arguments in C++, how many parameters are passed to the main function?
Read More Section(C plus plus miscellaneous)
Each Section contains maximum 100 MCQs question on C plus plus miscellaneous. To get more questions visit other sections.
- C plus plus miscellaneous - Section 1
- C plus plus miscellaneous - Section 2
- C plus plus miscellaneous - Section 3
- C plus plus miscellaneous - Section 4
- C plus plus miscellaneous - Section 5
- C plus plus miscellaneous - Section 7
- C plus plus miscellaneous - Section 8
- C plus plus miscellaneous - Section 9
- C plus plus miscellaneous - Section 10
- C plus plus miscellaneous - Section 11
