请教:
#define string80 char[80]
class CDate
{
public:
    CDate()
{ }
    CDate(int y,int m,int d)
{SetDate(y,m,d);}
void SetDate(int y,int m,int d)
{
Year=y;
Month=m;
Day=d;
} void GetStringDate(string80  &CDate)
{
sprintf(CDate,"%d/%d/%d",Year,Month,Day);
} protected
int Year,Month,Day;
};
编译时提示为:
Deleting intermediate files and output files for project 'Mytest13 - Win32 Debug'.
--------------------Configuration: Mytest13 - Win32 Debug--------------------
Compiling...
main.cpp
c:\program files\microsoft visual studio\myprojects\mytest13\date.h(16) : error C2143: syntax error : missing ')' before '&'
c:\program files\microsoft visual studio\myprojects\mytest13\date.h(16) : error C2143: syntax error : missing ';' before '&'
c:\program files\microsoft visual studio\myprojects\mytest13\date.h(16) : error C2059: syntax error : ')'
c:\program files\microsoft visual studio\myprojects\mytest13\date.h(17) : error C2580: redefinition of class name 'CDate'
        c:\program files\microsoft visual studio\myprojects\mytest13\date.h(16) : see declaration of 'CDate'
c:\program files\microsoft visual studio\myprojects\mytest13\date.h(17) : fatal error C1903: unable to recover from previous error(s); stopping compilation
Error executing cl.exe.Mytest13.exe - 5 error(s), 0 warning(s)
各位大哥,我是才错误在哪里啊?谢谢!

解决方案 »

  1.   

    void GetStringDate(string80  &CDate) //80是什么?是多写了
      

  2.   

    //#define  char[80]  string80//这句不要
    #include<string>
    #include<stdio.h>
    using namespace std;
    class CDate
    {
    public:
        CDate()
    { }
        CDate(int y,int m,int d)
    {SetDate(y,m,d);}
    void SetDate(int y,int m,int d)
    {
    Year=y;
    Month=m;
    Day=d;
    }void GetStringDate(char CDate[80])
    {
    sprintf(CDate,"%d/%d/%d",Year,Month,Day);
                          }protected:                  //protected  改为protected  :
    int Year,Month,Day;
    };
    void main()
    {}
      

  3.   

    非常感谢两位大哥:再向两位大哥请教一个问题问题1:
    using namespace std;这是用到了命名空间是吗?
    为什么要用命名空间?#include<string>
    #include<stdio.h>
    using namespace std;和 
    #include<string>
    #include<stdio.h>有什么区别啊?谢谢!
      

  4.   

    c++里面好像常有using namespace std;但我没怎么用过,觉得不用应该也没什么关系吧,不知道理解是否正确??