Constructor:
*It is a special type of method which will be executed automatically while crating an object
*Constructor name must be same as class name with out return type
syntax:
*These are used to initialize the variables to open files or database connection etc
Destructor:
*It will be executed automatically while destroying object
*The name of destructor must be same as class name with a ~(tild) prefix and with out return type and with out access specifiers
syntax:
*It is used to de-allocate the memory
*It is a special type of method which will be executed automatically while crating an object
*Constructor name must be same as class name with out return type
syntax:
public class_name()
{
}
*These are overlodabale*These are used to initialize the variables to open files or database connection etc
Destructor:
*It will be executed automatically while destroying object
*The name of destructor must be same as class name with a ~(tild) prefix and with out return type and with out access specifiers
syntax:
~class_name()
{
}
*These are not over lodable*It is used to de-allocate the memory
1 comment:
constructor does not have any return type not even void that means it does not return any value.
Post a Comment