| | |
C++
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Aug 2005
Posts: 80
Reputation:
Solved Threads: 2
A final class? You mean like a final variable in Java? I haven't heard of that before in C++. But to answer your question about making private constructors, the only reason why I could see you doing something like that would be in this case:
That way you could possibly do a kind of memory management..not sure how that ties in with a 'final' class, though.
-Fredric
C++ Syntax (Toggle Plain Text)
class Something { private: Something(); static list<Something *> somethings; public: static Something *New() { Something *something = new Something; somethings.push_back(something); return something; } //... }; // ... // In code somewhere Something *something = Something::New();
That way you could possibly do a kind of memory management..not sure how that ties in with a 'final' class, though.
-Fredric
>How Can i Create a final class in C++?
A "final" class in Java is a class that cannot be derived from, it's quite literally a concrete class that will never have subclasses. In C++ you basically can't do it without making the class harder to use. Are you doing this for the wrong reasons?
A "final" class in Java is a class that cannot be derived from, it's quite literally a concrete class that will never have subclasses. In C++ you basically can't do it without making the class harder to use. Are you doing this for the wrong reasons?
I'm here to prove you wrong.
![]() |
Other Threads in the C++ Forum
- Previous Thread: Help!!!!!!
- Next Thread: Concordance, Linked Lists and classes
| Thread Tools | Search this Thread |
api application array arrays based beginner binary bitmap bmp c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete deploy developer dll dynamiccharacterarray email encryption error file format forms fstream function functions game generator getline graph homeworkhelp homeworkhelper iamthwee ifstream image input int java lib list loop looping loops map math matrix memory multiple newbie news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg simple sorting string strings template text tree url vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






