i have the code fragment below,
is there anybody to explain me the meaning of this syntax:
BadIndex(int i) : badindex(i) {}
is it the same with this:
BadIndex(int i) {badindex=i; }
if it is the same why the former one is used instead of the latter?
[code=cpp]class BadIndex // exception class for indexing problems
{
private:
int badindex; // problematic index value
public:
BadIndex(int i) : badindex(i) {}
virtual void Report() const;
};[/code]
is there anybody to explain me the meaning of this syntax:
BadIndex(int i) : badindex(i) {}
is it the same with this:
BadIndex(int i) {badindex=i; }
if it is the same why the former one is used instead of the latter?
[code=cpp]class BadIndex // exception class for indexing problems
{
private:
int badindex; // problematic index value
public:
BadIndex(int i) : badindex(i) {}
virtual void Report() const;
};[/code]
Comment