Technical Interview Questions and Answers :: TCS
- Select All
- SQL
- Java
- C++
- WebMethod
- Informatica
- C
- DBMS
- Operating System
- Soft. Engineering
- Data Structure
- Networking
- Hadoop
- HR Question in TR
31 / 158
Object is a software bundle of variables and related methods. Objects have state and behavior.
32 / 158
Constructor is used to initialise class variable when object of class is created
33 / 158
Structure: Initially (in C) a structure was used to bundle different type of data types together to perform a particular functionality. But C++ extended the structure to contain functions also. The major difference is that all declarations inside a structure are by default public.
Class: Class is a successor of Structure. By default all the members inside the class are private.
34 / 158
Friend classes are used when two or more classes are designed to work together and need access to each others implementation in ways that the rest of the world shouldn’t be allowed to have. In other words, they help keep private things private. For instance, it may be desirable for class Database Cursor to have more privilege to the internals of class Database than main () has.
35 / 158
Container class is a class that hold group of same or mixed objects in memory. It can be heterogeneous and homogeneous. Heterogeneous container class can hold mixed objects in memory whereas when it is holding same objects, it is called as homogeneous container class.
36 / 158
By using a friend function.
A friend function has access to all private and protected members of the class for which it is a friend.
37 / 158
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.
38 / 158
Friend Function:
A friend function can access a class private data, even though it is not a member function of the class. This is useful when one function must have access to two or more unrelated classes and when an overloaded operator must use, on its left side, a value of a class other than one of which it is a member. Friends are also used to facilitate functional notation.
Friend Class:
It is possible to grant a non-member function access to the private members of a class by using a friend. A friend function has access to all private and protected members of the class for which it is a friend.
39 / 158
No Discussion on this question yet!
40 / 158
Now Class B