+ 7

Can constructor and destructor can be inherited?

7th Sep 2020, 12:43 PM
Sufia Hashmi
Sufia Hashmi - avatar
49 Antworten
+ 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..
7th Sep 2020, 6:19 PM
Aditya
Aditya - avatar
+ 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.
7th Sep 2020, 1:01 PM
Aditya
Aditya - avatar
+ 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 😄
7th Sep 2020, 9:26 PM
Aditya
Aditya - avatar
+ 7
D_Stark I'm only aware of constructor inheritance in C++. Adding to the list by ~ swim ~, C# does not support it either. Ipang Good point about a grace period. @~ swim ~: I love how the downvote abusers think they are protected by anonymity. 😉 I'll leave it at that. 😉
8th Sep 2020, 1:45 PM
David Carroll
David Carroll - avatar
+ 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.
7th Sep 2020, 1:10 PM
D_Stark
D_Stark - avatar
+ 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 : )
8th Sep 2020, 1:20 PM
Ipang
+ 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.
8th Sep 2020, 2:03 PM
David Carroll
David Carroll - avatar
+ 6
GUNWAL THE GAMERS , Subani1 please don't post irrelevant answers.. please delete this..so that I can delete this.
9th Sep 2020, 11:39 AM
Aditya
Aditya - avatar
+ 5
The inheritance of constructors and destructors depends on the type of invocation being implemented.
7th Sep 2020, 12:56 PM
Aditya
Aditya - avatar
+ 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.
7th Sep 2020, 1:40 PM
Aditya
Aditya - avatar
+ 5
Aditya / ~ swim ~ Thanks for the clarification. I guess I would no longer be eligible even if I was a citizen of India because I've already "attained an age" that exceeds the maximum eligibility. In closing this tangent, this is the first time I've ever seen the expression "attain the age". 😉👌
7th Sep 2020, 8:52 PM
David Carroll
David Carroll - avatar
+ 5
David Carroll does constructor inheritance apply only to c++ because java doesn't seem to support this.
8th Sep 2020, 1:16 PM
D_Stark
D_Stark - avatar
+ 4
Option 3. I choose. Both constructor cannot be inherited., automatically invoked. And contrcmuctor can be called explicitly from subclass...
7th Sep 2020, 3:07 PM
Jayakrishna 🇮🇳
+ 4
Constructor cannot have return type then how it is called a constructor...? D_Stark
7th Sep 2020, 3:11 PM
Jayakrishna 🇮🇳
+ 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. 🤷‍♂️
7th Sep 2020, 6:16 PM
David Carroll
David Carroll - avatar
+ 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.
8th Sep 2020, 1:00 PM
David Carroll
David Carroll - avatar
+ 3
David Carroll its a great way to mask age discrimination by using unfamiliar wordings 😅
7th Sep 2020, 8:58 PM
D_Stark
D_Stark - avatar
+ 3
not on java
8th Sep 2020, 10:17 PM
Shabas Tech
Shabas Tech - avatar
+ 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.
9th Sep 2020, 6:12 AM
Raj Srivastava
Raj Srivastava - avatar
+ 2
Here a quick example I made to show you. fixed errors https://code.sololearn.com/cUvIWr1n1Ynd/?ref=app
7th Sep 2020, 1:36 PM
D_Stark
D_Stark - avatar