Could someone explain some code?

V

Victor Bazarov

Francis said:
But, unless I have completely lost track, we were not discussing a
header (I have never come across a header with main() in it.

You have completely lost track, then. See the post that started the
thread. The two lines quoted _were_ in a header. And I don't see any
'main' in it either.

V
 
D

Default User

Francis said:
But, unless I have completely lost track, we were not discussing a
header (I have never come across a header with main() in it.

Nope. Here's the original code under discussion:

-----------

#ifndef _COUNTER_H
#define _COUNTER_H
#include <iostream>
using namespace std;

class Counter
{
public:
int count;
public:
* Counter(){count = 0;}
void operator ++() { ++count; }
int GetCount() { return count; }
void SetCount( int c ) { count = c; }
void PrintCount() { cout << "\n The count is " << count; }

};

class NewCounter:public Counter
{
public:
* void operator --() { --count; }
};

#endif

Much better is to actually understand what using declarations and
using directives do.

Indeed. Feel up to posting a tutorial? I didn't. The people in question
should find a good book that explains the subject. Now, if we only knew
of some web site or something that reviewed books ;)




Brian
 
J

jeffc

Victor Bazarov said:
Lose the leading underscore on that macro name.


This is a very bad idea. Try to avoid ever putting 'using' directives
in a header.


This one declares and defines the default constructor for this class.

I thought the * was actually part of the code, and I could not figure out what
it was supposed to do :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top