Re: Could someone explain some code?
Gactimus wrote:
[color=blue]
> Can anyone explain what the lines with the '*' by them do?
>
> -----------
>
> #ifndef GUARD_COUNTER_H
> #define GUARD_COUNTER_H 1
> #include <iostream>
> // using namespace std;
>
> class Counter {
> private:
> int count;
> public:
> Counter(void): count(0) { } // default constructor
> Counter& operator++(void ) { ++count; return *this; }
> int GetCount(void) { return count; }
> Counter& SetCount(int c) { count = c;[/color]
return *this; }
friend
std::ostream& operator<<(std: :ostream& os, const Counter& c) {
return os << c.count;
}[color=blue]
> // void PrintCount() { cout << "\n The count is " << count; }
>
> };
>
> class NewCounter: public Counter {
> public:
> NewCounter& operator--(void) { --count; return *this; }
> };
>
> #endif//GUARD_COUNTER_H[/color]
Gactimus wrote:
[color=blue]
> Can anyone explain what the lines with the '*' by them do?
>
> -----------
>
> #ifndef GUARD_COUNTER_H
> #define GUARD_COUNTER_H 1
> #include <iostream>
> // using namespace std;
>
> class Counter {
> private:
> int count;
> public:
> Counter(void): count(0) { } // default constructor
> Counter& operator++(void ) { ++count; return *this; }
> int GetCount(void) { return count; }
> Counter& SetCount(int c) { count = c;[/color]
return *this; }
friend
std::ostream& operator<<(std: :ostream& os, const Counter& c) {
return os << c.count;
}[color=blue]
> // void PrintCount() { cout << "\n The count is " << count; }
>
> };
>
> class NewCounter: public Counter {
> public:
> NewCounter& operator--(void) { --count; return *this; }
> };
>
> #endif//GUARD_COUNTER_H[/color]
Comment