You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Because it returns actual object and be assigned to a new object from GPIO_Device, copy constructor of the class is invoked and since the copy constructor of class is deleted it causes syntax error.
Fundamental Reason to Use Reference
In a Singleton pattern, the goal is to ensure that there is only one instance of a class. Returning a reference or pointer to that instance, instead of an object, helps ensure that there is only one instance of the class in the entire system. This allows other parts of the system to access the Singleton without accidentally creating new instances of it.
Calling it by value is against the nature of Singleton pattern cause it creates more than one object.
The text was updated successfully, but these errors were encountered:
Problem Description
Singleton design pattern is implemented to child device classes successfully:
However it turns out to be a syntax error if it returns the actual object (namely call by value) instead of reference
Problem Reason
When it called by value like below,
Because it returns actual object and be assigned to a new object from GPIO_Device, copy constructor of the class is invoked and since the copy constructor of class is deleted it causes syntax error.
Fundamental Reason to Use Reference
In a Singleton pattern, the goal is to ensure that there is only one instance of a class. Returning a reference or pointer to that instance, instead of an object, helps ensure that there is only one instance of the class in the entire system. This allows other parts of the system to access the Singleton without accidentally creating new instances of it.
Calling it by value is against the nature of Singleton pattern cause it creates more than one object.
The text was updated successfully, but these errors were encountered: