Technical Interview Questions and Answers :: Societe Generale
- Select All
- Oracle PLSQL
- SQL
- Java
- C++
- Informatica
- WebMethod
- DBMS
- C
- Soft. Engineering
- Data Structure
- HR Question in TR
1 / 75
No Discussion on this question yet!
2 / 75
Yes, struct is similar to class, only all attributes/methods are public by default in the struct. You can very well have methods and attributes in a struct. You can also inherit from a struct (default inheritance is public).
3 / 75
4 / 75
Yes, Size of an empty class is not zero. It is 1 byte generally. It is nonzero to ensure that the two different objects will have different addresses.
5 / 75
Now Class B
6 / 75
Copy constructor is used to declare and initialize an object from another object.
For example, the statement
Integer I2(I1);
Would define the object I2 and at the same time initialize it to the values of I1. another form of this statement is integer I2=I1;
The process of initializing through a copy constructor is known as copy initialization. A copy constructor takes a reference to an object of the same class as itself as an argument.
7 / 75
No Discussion on this question yet!
8 / 75
Syntax:
void operator delete(void *p)
{
/*free memory pointed to by p. the destructor is called automatically.*/
}
The delete function receives a pointer to the region of memory to be freed. It then releases the previously allocated memory back to the system. When an object is deleted, its destructor is automatically called.
9 / 75
A constructor that accepts no parameters is called the default constructor. The default constructor for class A is A::A ( ). If no such constructor is defined, then the compiler supplies a default constructor. Therefore a statement such as A a;
Invokes the default constructor of the compiler to create the object a.
10 / 75
A constructor is declared and defined as
Class integer
{
int m,n;
public:
integer(void); //constructor declared
……….
………..
};
integer : : integer(void)//constructor defined
{
m=0;
n=0;
}