|
-
July 28th, 2010, 03:32 AM
#1
vector private inheritance
So I have a class which is implemented "as a" vector. => vector private inheritance.
No public client is supposed to know that my class derives from vector, and since the inheritance is private, the client shouldn't be able to handle my class via vector* anyways.
I don't have a single virtual function
Further more, my class has no members, it is purely implemented as a vector.
I don't intend to have any public children (though I will implement a single private child, which will also be implemented "as a")
I get no warnings from the standard MinGW with max anal options (strict etc), but when I activate "Enable Effective C++ warnings (thanks Scott Meyers) [-WEffc++]", I get:
Code:
warning: base class 'class std::vector<unsigned char, std::allocator<unsigned char> >' has a non-virtual destructor
Now I understand the warning, and that Effective C++ are more of "are you sure?" rather than "It's legal, but undefined" and but I'm fairly certain I'm safe, but I still have some doubts. So I thought I'd pass my design through here.
My two questions:
1) Am I safe? Did I miss something?
2) What are the risks that I mess up in the future? What are some of the ways I can break my design? I mean, as long as the base class is never called via pointer to destroy an instance of my class, I'm 100% safe, right?
I realize I could just go for agregation, but it just isn't as practical. And less fun
Is your question related to IO?
Read this C++ FAQ article at parashift by Marshall Cline. In particular points 1-6.
It will explain how to correctly deal with IO, how to validate input, and why you shouldn't count on "while(!in.eof())". And it always makes for excellent reading.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|