Where have you used UDP Socket Programming?

Answer: The answer is up to you if you have used UDP socket programming in your project. If you have not used in your project or you are a fresher, then you can say that you have not used, but you can answer the concept where we can use upd socket programming in real time…

Read the full article

What does bind() function do in TCP/UDP server?

Answer: Bind() function in socket programming is used to associate the socket with local address i.e. IP Address, port and address family. int bind(int sockfd,struct sockaddr *servaddr,int addrlength); There could be many combination of IP address and ports e.g. (10.17.18.19, 6400), (10.17.18.19, 6500), (10.17.18.19, 6600) and so on, a server can use. Let’s say we…

Read the full article

What are issues if we mix new and free in C++?

Answer: new and free in c++ should never be mixed or else we may get memory leak issues and resource leak issues and may take extra effort and time to maintain the C++ software project.Memory leak really a not a good elements for software and cause poor performance to a software.   Recommended to read…

Read the full article

Code for C++ delete singleton instance

Answer:To delete singleton instance or object in C++ programs, we need to follow a proper design to delete singleton object in the class . Especially, when multiple users are using object of singleton class in c++ program. One of the bad situations we can think that what if one user has deleted singleton object while…

Read the full article

Design Singleton class for multi-threaded environment in C++

Answer: For c++ thread safe singleton class design for multi threaded environment, we need to synchronize the function that creates and returns singleton object. We will see the singleton class design without synchronization and with synchronization applying on function that create singleton object in C++ For example, in the below design “GetInstance()”  function is not…

Read the full article

this pointer in C++ – how does it work internally?

Answer: The this pointer in C++ is a constant pointer that stores address of an object of a class. The type of this pointer is the type of object it is pointing to.  For example, if we have a class named ‘sample’, the type of this pointer is ‘sample* const this’. (What is type of…

Read the full article

Design Singleton class in C++ with example – Simple Steps

Answer: Singleton class in C++ is the class that is designed to provide only one unique instance across the system. So, whenever we create c++ singleton instance, it will return the same instance created earlier if any. About method and variables for Designing Singleton class in C++ Singleton class requires below methods and variables. Private…

Read the full article

Difference between new and malloc in C++ – Including Performance

Difference between new and malloc in C++  – The answer of  interview question C++ malloc vs new heap memory allocation includes advantages of new operator over malloc function in C++ programming language. Also, discussion about performance of new and malloc, free() function and delete operators are included. Note that in a technical interview, generally, it is…

Read the full article

What is size of Empty Class in C++ with virtual function?

Answers contains the size of empty class in C++ with virtual function (4 or 8 bytes) and without virtual function (1 byte not 0 ) with reason and example. Answer: Size of empty class in C++ Size of empty class in C++ is 1 byte and not 0 byte without virtual function, whereas, with virtual…

Read the full article

How do you prevent heap allocation in C++ for a Class?

C++ Interview Question Description: Describe the concept to prevent heap allocation in C++ for a class i.e. object creation on heap. Means, dynamic memory allocation using new operator. Note that we don’t want to restrict object creation in stack in C++ class. So, explain how to prevent object creation on heap with a program example.…

Read the full article