+ 7
Can constructor and destructor can be inherited?
41 Réponses
+ 11
David Carroll sir you can see this..
https://en.m.wikipedia.org/wiki/Civil_Services_Examination_(India)
Edit : It's an entrance examination [The Civil Services Examination (CSE)] is a nationwide competitive examination in India conducted by the Union Public Service Commission for recruitment to various Civil Services of the Government of India, including the Indian Administrative Service (IAS), Indian Foreign Service (IFS), and Indian Police Service (IPS)
Gratitude Aptitude of Technology (GATE) is an entrance exam for master's in any field in India(for any bachelor program).
//No they are not necessary..
+ 8
In situations where both class have a constructor, then the priority is given to the one from the parent class which is called first while in case of destructor it’s the child class which gets the priority.
Generally, we add constructor or destructor class in either the child or the parent class only to avoid conflict.
Edit : Whether it may upsc or a gate examination it depends on the framework of questions and the nearest option available to be marked as crrt.
+ 7
David Carroll, D_stark that might be a bit true..but you all have huge knowledge and experience.. you can crack this exam easily 😄
+ 6
Constructors and destuctors are not members of the class and not inherited but instead automatically invoked if the sub class has no constructor.
up to now this excludes c++ which supports constructor inheritance.
+ 6
David Carroll
In other forums thread locking is possible, and I really understand the purpose. But oftenly enough I found (in other forums) that a best answer also has a sort of grace period. I mean an answer that was related, correct, detailed and valid at a time may not be true in the future, as we can see from ~ swim ~'s answer, a new feature in a language changes the definition of what best answer is.
Time changes things, apparently : )
+ 6
🤦♂️ Nandi Vardhan Read the past few messages posted. You might find it informative.
---
Anyway... I'm unfollowing this post due to the never-ending duplicate wrong answers that will follow. Mention me by name if you want me to see your followup posts.
+ 6
GUNWAL THE GAMERS , Subani1 please don't post irrelevant answers.. please delete this..so that I can delete this.
+ 5
The inheritance of constructors and destructors depends on the type of invocation being implemented.
+ 5
It's Me option 1 : Destructor cannot be inherited.
Reason : destructor can't be inherited after the scope of object goes out.
//This is what I know..I may be wrong.
+ 5
David Carroll does constructor inheritance apply only to c++ because java doesn't seem to support this.
+ 4
Option 3. I choose.
Both constructor cannot be inherited., automatically invoked. And contrcmuctor can be called explicitly from subclass...
+ 4
Constructor cannot have return type then how it is called a constructor...? D_Stark
+ 4
What the heck is a UPSC exam?
I found something related to https://en.m.wikipedia.org/wiki/Union_Public_Service_Commission, but that seems like something for a governmental agency in India.
Is this for a software engineering job for the government in India? If so, is this common in other countries?
I'm not familiar with anything like this in the USA. I could just be unaware. 🤷♂️
+ 4
Haadia Amjad / Vishal kumar Patel (Vishu) Please review the answers posted by ~ swim ~ .
Since C++11, constructor inheritance has been supported with the use of the using statement.
It's Me You should select a best answer and append [Resolved] to this question to minimize the many random guesses that will follow from people who don't review the previously posted answers.
Sigh... I wish we could lock down questions.
+ 3
David Carroll its a great way to mask age discrimination by using unfamiliar wordings 😅
+ 3
not on java
+ 3
Constructors aren't a part of objects' interface. They belong directly to classes. Classes A and B may provide completely different sets of constructors. No "being inherited" here.
(Implementation detail: each B's constructors calls some A's constructor.)
Destructors indeed are a part of each object's interface, since the object's user is responsible for calling them (i.e. directly with delete or indirectly by letting an object out of scope). Each object has exactly one destructor: its own destructor, which might optionally be a virtual one. It is always its own, and it's not inherited.
+ 2
Here a quick example I made to show you.
fixed errors
https://code.sololearn.com/cUvIWr1n1Ynd/?ref=app