/DSA-PRACTICE-QUESTIONS

All the DSA problems ranging from easy to hard are practiced and solved here.

Primary LanguageC++

DSA-PRACTICE-QUESTIONS

All the DSA problems ranging from easy to hard are practiced and solved here. Here are some important pointers from C++ that are needed to be kept in mind. C++ Interview Questions:

• There are four type of data types in C++:

  1. Primitive: int, char, float, long, double
  2. Derived data types: arrays, stack, queue, linked list
  3. Enumeration: enum
  4. User defined data types: class and struct

• Class is a user defined data type that has data members and member functions. Whereas object is just an instance of the class that define the behavior of the class.

• Members and access specifier of struct are public in nature. Members and access specifier of class are private in nature.

• Operator overloading is a method that is used to modify the functionality of the operators.

• Polymorphism means many forms. There are two types of polymorphism runtime and compile time polymorphism. Runtime polymorphism include: function overloading and operator overloading whereas compile time polymorphism includes virtual functions and function overriding.

• Constructor has same name as the class it is the member function of the class that has no return type and is called automatically by the compiler at the time of compilation.

• Virtual function is the member function of the base class which is redefined in the derived class. It is used using virtual keyword.

• In compile time polymorphism we would know at compile time which method will be called. Its execution is faster as it is known at the compile time. In runtime polymorphism we wouldn’t know at compile time which method has to be called, we come to know about it at runtime therefore the execution is slower in runtime compilation.

• A friend class is used to access private, protected and public members of the classes It is declared a friend of. Friend function is not a member function.

• In call by value, the parameters passed have a separate copy in the memory and the changes made are not made in actual parameters. In call by reference the address of the variable are passed as parameters, so the changes are directly made in the actual variables.

• Abstract classes are the classes whose objects can never be created. We can create an abstract class by declaring a pure virtual function in the class.

• Copy constructor is a member function whose object is created using another object.

• Shallow copy stores the reference of the variable to the actual address. It makes changes to the actual variable. It is faster than deep copy.

• Deep copy makes a new memory for the copy and doesn’t change the actual value in the memory it makes changes it its own copy. It is slower than the shallow copy.

• Void pointer is a pointer that has no data type associated with it can store address of any type of data.