shubhamchawla00
BAN USER- 1 Answer Google Interview Question
Generally it is preferred to pass pointer to structure to a function in C, in order to avoid copying during function call. This has an unwanted side effect that the called function can modify the elements of the structure inadvertently. What is a good programming practice to avoid such errors without compromising on the efficiency of the function call ?
- shubhamchawla00 October 17, 2014| Flag | PURGE - 1 Answer Amazon written test
Assuming int to be of 4 bytes, what is the size of class Derived ?
- shubhamchawla00 October 17, 2014
class Base {
protected:
int x;
public:
Base(int x_) : x(x_) {}
int get_x(void) { return x; }
};
class Derived : public Base {
int y;
public:
Derived(int x_,int y_) : Base(x_), y(y_) {}
int get_y(void) { return y; }
};| Flag | PURGE - 1 Answer Amazon written test
What will be the output of the following C++ program ?
- shubhamchawla00 October 17, 2014
#include <iostream>
class A {
int x;
int y;
int z;
public:
A() : x(5), y(10), z(15) {}
A (A const & a) {}
int get_x(void) { return x; }
};
int main() {
A a;
A aa(a);
std::cout << aa.get_x() << std::endl;
return 0;
}| Flag | PURGE