+ 1
Is there a way I can avoid using constructors and destructors but still doing the same function
Constructors & destructors...
6 Answers
+ 10
Yes if you wanted to but the complier will still provide a default for both.
+ 4
Which language?
And can you explain what exactly you want to do?
And why do you want to evade constructors and destructors?
+ 1
If you code in c, there is struc, but no class or constructors and destructors. If I make a non trivial structure in c, then I would make an initialize function and delete function for it. (At least that's what I did with my linked list implementation. )
When ever I make a new struc I have to manually call the initialize function, then call the delete function when I'm finished with it.
You could take this approach in c++, but you should ask yourself why.
0
C++
0
The general use of constructors
0
Thank u all