I wouldn't go so far as to say that a base class implementing the copy/move operations or the destructor is a strong indication that a derived class should. The compiler generated defaults will call the base class versions. If your base class requires derived classes to do anything more than that then that's a pretty good indication that the base class versions are implemented incorrectly.
- Viewing Profile: Reputation: SiCrane
Community Stats
- Group Moderators
- Active Posts 20,856
- Profile Views 10,501
- Member Title Not Getting Enough Sleep
- Age Age Unknown
- Birthday Birthday Unknown
-
Gender
Not Telling
User Tools
#5070995 Why only the = operator is not inherited?
Posted by SiCrane
on Yesterday, 07:19 PM
#5070970 Why only the = operator is not inherited?
Posted by SiCrane
on Yesterday, 04:44 PM
It is inherited. However, unlike other operators, a derived class will generate an implicitly defined assignment operator that will hide the base class version. However, with explicit qualification the derived class can access the base class version if it wants to.
#5070228 POD structs and the Assignment operator
Posted by SiCrane
on 16 June 2013 - 01:43 PM
#5070154 POD structs and the Assignment operator
Posted by SiCrane
on 16 June 2013 - 08:47 AM
First note: your Player class isn't POD. In order to be POD all the member variables also have to be POD and your Player class contains a std::string object. As for overloading the assignment operator, if you don't define an assignment operator the compiler will define an assignment operator that does a member by member assignment. If you want your assignment operator to do something different than calling the assignment operator for each of the member variables then you create your own assignment operator implementation.
#5070055 C++ vector of class objects referencing external class
Posted by SiCrane
on 15 June 2013 - 04:59 PM
Every time you use push_back() to put something in a vector, the vector makes a copy of the object you pass it. If you pass push_back() a temporary object, the vector will make a copy of the temporary and then the compiler will destroy the temporary. It's also possible that they way you're reading from the vector is also generating extra temporary objects.
How are you tracking your CUnit destruction? It's entirely possible that you aren't seeing matching construction and destruction counts because you aren't tracking copy constructor calls.
#5069495 Using nonvirtual inheritance for informal 'interfaces'?
Posted by SiCrane
on 13 June 2013 - 12:44 PM
I don't really see the point. If you try calling a member function on a class that doesn't support it you'll get a compiler error even without any tricky base class usage.
#5069211 Function pointer as unique [system] id
Posted by SiCrane
on 12 June 2013 - 01:57 PM
If you create a pointer to a member function for a virtual function what you'll get is a member function pointer that always calls the most derived function implementation for that virtual function.
#5068430 Debugging
Posted by SiCrane
on 09 June 2013 - 09:46 AM
#5068226 store values from string in an array
Posted by SiCrane
on 08 June 2013 - 07:27 AM
#5066578 *Want* Multiple Base Objects
Posted by SiCrane
on 31 May 2013 - 08:13 PM
template <int i> struct BaseHelper : FBO2D {
// add appropriate forwarding functions
};
struct FBOCube : BaseHelper<0>, BaseHelper<1>, BaseHelper<2>, BaseHelper<3>, BaseHelper<4>, BaseHelper<5> {
};
#5065895 What am I missing here?
Posted by SiCrane
on 29 May 2013 - 12:44 PM
As a side note, you're passing std::vector objects around by value which can be rather inefficient; you may want to switch to pass by reference instead.
#5065371 std::bind and function
Posted by SiCrane
on 27 May 2013 - 06:20 PM
#5063980 expected template ambiguity
Posted by SiCrane
on 22 May 2013 - 05:44 PM
#5063345 Convert std::string to WCHAR ?
Posted by SiCrane
on 20 May 2013 - 05:27 PM
- Home
- » Viewing Profile: Reputation: SiCrane

Find content