有人可以解释一些代码吗? [英] Could someone explain some code?
问题描述
任何人都能解释一下他们用''*'表示的行吗?
-----------
>
#ifndef _COUNTER_H
#define _COUNTER_H
#include< iostream>
使用命名空间std;
班级柜台
{
公开:
int count;
public:
* Counter(){count = 0;}
void operator ++(){++ count; }
int GetCount(){return count; }
void SetCount(int c){count = c; }
void PrintCount(){cout<< \ n计数是 <<计数; }
};
class NewCounter:公共柜台
{
public :
* void operator - (){ - count; }
};
#endif
Gactimus写道:< blockquote class =post_quotes>任何人都可以用它们来解释带有''*'的行吗?
-----------
> #ifndef _COUNTER_H
#define _COUNTER_H
丢失该宏名称的前导下划线。
#include< iostream>
using namespace std;
这是一个非常糟糕的主意。尽量避免在标题中加入''使用''指令
。
班级计数器
{
公开:
int count ;
public:
* Counter(){count = 0;}
这个声明并定义了这个类的默认构造函数。
void operator ++(){++ count; }
int GetCount(){return count; }
void SetCount(int c){count = c; }
void PrintCount(){cout<< \ n计数是 <<计数;新课程:NewCounter:公共计数器
{
公开:
* void operator - (){--count ; }
这个声明并为''NewCounter'定义一个预减量运算符'
};
#endif
V
Victor Bazarov< v。******** @ comAcast.net>写在
新闻:Gi ***************** @ newsread1.dllstx09.us.to。 verio.net:
Gactimus写道:
任何人都可以用它们来解释带有''*'的行吗?
-----------
#ifndef _COUNTER_H
#define _COUNTER_H
失去领先强调该宏名称。
#include< iostream>
使用命名空间std;
这是一个非常糟糕的主意。尽量避免在标题中加入''使用''指令
。
班级计数器
{
公开:
int count;
public:
* Counter(){count = 0;}
这个声明并定义了这个类的默认构造函数。
void operator ++(){++ count; }
int GetCount(){return count; }
void SetCount(int c){count = c; }
void PrintCount(){cout<< \ n计数是 <<计数;
}
};
类NewCounter:公共柜台
{
公开:
* void operator - (){ - count; }
这个声明并为''NewCounter''定义一个预减量运算符
谢谢。
Gactimus写道:
[代码帮助剪断]
你应该给自己一份 Koenig和Moo加入C ++
。在C ++研究的早期,让自己走上正确的道路
。在你完成
之后,你应该在www.accu.org上对带有好评的书籍进行抽样
。
袜子
Can anyone explain what the lines with the ''*'' by them do?
-----------
#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
Gactimus wrote:Can anyone explain what the lines with the ''*'' by them do?
-----------
#ifndef _COUNTER_H
#define _COUNTER_H
Lose the leading underscore on that macro name.
#include <iostream>
using namespace std;
This is a very bad idea. Try to avoid ever putting ''using'' directives
in a header.
class Counter
{
public:
int count;
public:
* Counter(){count = 0;}
This one declares and defines the default constructor for this class.
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; }
This one declares and defines a pre-decrement operator for ''NewCounter''
};
#endif
V
Victor Bazarov <v.********@comAcast.net> wrote in
news:Gi*****************@newsread1.dllstx09.us.to. verio.net:
Gactimus wrote:Can anyone explain what the lines with the ''*'' by them do?
-----------
#ifndef _COUNTER_H
#define _COUNTER_H
Lose the leading underscore on that macro name.#include <iostream>
using namespace std;
This is a very bad idea. Try to avoid ever putting ''using'' directives
in a header.
class Counter
{
public:
int count;
public:
* Counter(){count = 0;}
This one declares and defines the default constructor for this class.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; }
This one declares and defines a pre-decrement operator for ''NewCounter''
Thank you.
Gactimus wrote:
[code help snipped]
You should get yourself a copy of "Accelrated C++"
by Koenig and Moo. Get yourself on the right path
early in your C++ studies. After you''ve got through
that, you should sample the books with good reviews
at www.accu.org.
Socks
这篇关于有人可以解释一些代码吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!