ExamVeda
Login
Home
61
Which is the correct example of a binary operator?
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
62
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
int main ()
{
  string str = "HelloWorld!";
  cout<<str.capacity();
  cout<<str.size();
  return 0;
}
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
63
What will be the output of the following C++ code?
#include <iostream> 
#include <string>
#include <cstring>
using namespace std; 
int main(int argc, char const *argv[])
{
	string s("a");
	cout<<s;
	return 0;
}
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
64
Which of the following operator can be used to overload when that function is declared as friend function?
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
65
What will be the output of the following C++ code?
#include <iostream> 
#include <string>
using namespace std; 
int main(int argc, char const *argv[])
{
	char s1[6] = "Hello";
	char s2[6] = "World";
	char s3[12] = s1 + " " + s2;
	cout<<s3;
	return 0;
}
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
66
The data members and functions of a class in C++ are by default . . . . . . . .
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
67
How many arguments will the subscript operator will take for overloading?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
68
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
class A
{
	static int a;
    public:
	A()
        {
		cout<<"Object of A is created\n";
	}
	void show()
        {
		a++;
		cout<<"a: "<<a<<endl;
	}
};
 
class B
{
    public:
};
 
int main(int argc, char const *argv[])
{
	A a1, a2;
	A a3 = a1 + a2;
	return 0;
}
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
69

#include <iostream>
using namespace std;
class three_d 
{
    int x, y, z;
    public:
    three_d() { x = y = z = 0; }
    three_d(int i, int j, int k) { x = i; y = j; z = k; }
    three_d operator()(three_d obj);
    three_d operator()(int a, int b, int c);
    friend ostream &operator<<(ostream &strm, three_d op);
};
three_d three_d::operator()(three_d obj)
{
    three_d temp;
    temp.x = (x + obj.x) / 2;
    temp.y = (y + obj.y) / 2;
    temp.z = (z + obj.z) / 2;
    return temp;
}
three_d three_d::operator()(int a, int b, int c)
{
    three_d temp;
    temp.x = x + a;
    temp.y = y + b;
    temp.z = z + c;
    return temp;
}
    ostream &operator<<(ostream &strm, three_d op) {
    strm << op.x << ", " << op.y << ", " << op.z << endl;
    return strm;
}
int main()
{
    three_d objA(1, 2, 3), objB(10, 10, 10), objC;
    objC = objA(objB(100, 200, 300));
    cout << objC;
    return 0;
}
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
70
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
class sample
{
    private:
    int* i;
    int j;
    public:
    sample (int j);
    ~sample ();
    int& operator [] (int n);
};
int& sample::operator [] (int n)
{
    return i[n];
}
sample::sample (int j)
{
    i = new int [j];
    j = j;
}
sample::~sample ()
{
    delete [] i;
}
int main ()
{
    sample m (5);
    m [0] = 25;
    m [1] = 20;
    m [2] = 15;
    m [3] = 10;
    m [4] = 5;
    for (int n = 0; n < 5; ++ n)
    cout << m [n];
    return 0;
}
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board