|
![]() Click on image to see enlargment |
|
PC-lint/FlexeLint Output | Reference Manual Explanation | Home bug1538.cpp
This is part of a program written by a florist. Its purpose is to assess the color of various flowers. He was shocked, though, when the program declared that roses were colorless. Where did he goof? bug1538.cpp lint Output
--- Module: bug1538.cpp (C++)
_
Flower(const Flower & f) :color(f.color) { }
bug1538.cpp(6) : Warning 1554: Direct pointer copy of member 'Flower::color'
within copy constructor: 'Flower::Flower(const Flower &)'
_
Rose( const Rose & ) { }
bug1538.cpp(13) : Warning 1538: base class 'Flower' absent from initializer
list for copy constructor
_
}
bug1538.cpp(19) : Info 1746: parameter 'r' in function 'print(Rose)' could be
made const reference
Reference Manual Explanation
1538 base class 'Name' absent from initializer list for copy constructor -- The
indicated base class did not appear in the initializer list for a copy
constructor. Was this an oversight? If the initializer list does not
contain an initializer for a base class, the default constructor is used
for the base class. This is not normally appropriate for a copy constructor.
The following is more typical:
class B { ... };
class D : public B
{
D( const D &arg ) : B( arg ) { ... }
...
};
If you have comments or questions about this bug, please post them to our Discussion Forum |
Previous Bug - Bug #505 - April 2007