Thread: Newbie help

  1. #1

    Newbie help

    Newbie here needs some help, I have to use this header file as is, i can not modify it. I have only worked on 3 functions and i am having problems....please help

    // header file
    class Date
    Date(int m = MM, int d = DD, int y = YY, const char *name = NA);
    void setDate(int m, int d, int y, const char *name = NA);
    ~Date();			//destructor
    void print() const;	//display data
    void cinDate();		//cin the date
    int theMonth;
    int theDay;
    int theYear;
    char *theName;
    void setString(const char *str);	//utility function
    // implementation
    Date::Date(int m, int d, int y, const char *name)
    { setDate(m, d, y, const char *name); }
    void Date::setDate(int m, int d, int y, const char *name)
    theMonth = (m >= 1 && m <= 12) ? m : MM;
    theDay = (d >= 1 && d <= 31) ? d : DD;
    theYear = (y >= 0 && y <= MAX_YY) ? y : YY;
    setString(const char *str);
    void Date::print() const
    cout << "theMonth" << " theDay" << "," << " theYear" << endl;
    the void setdate function is suppose to validate parameters and sets all data components. If parameters are out of range, defaults will be used. The function setString() to set up theName.

    Date.....The constructor has four args. Its also default constructor. The function calls setDate() to init the components. (did i call the function right?)

    I get these four errors
    error C2059: syntax error : 'const'
    : error C2143: syntax error : missing ')' before 'const'
    : error C2660: 'setString' : function does not take 0 parameters
    : error C2059: syntax error : ')'

  2. #2
    geek SilentStrike's Avatar
    Join Date
    Aug 2001
    Date::Date(int m, int d, int y, const char *name)
    // { setDate(m, d, y, const char *name); } // should be
    { setDate(m, d, y, name); }
    You don't need the types of the arguments when calling functions, the compiler already knows the type of every named variable in your program. You need to change your setString call as well.
    Prove you can code in C++ or C# at TopCoder, referrer rrenaud
    Read my livejournal

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. getting to grips with allegro and ms vc++ (newbie)
    By jimjamjahaa in forum C++ Programming
    Replies: 4
    Last Post: 11-18-2005, 07:49 PM
  2. Newbie in problem with looping
    By nrain in forum C Programming
    Replies: 6
    Last Post: 11-05-2005, 12:53 PM
  3. Newbie Programmer
    By Extropian in forum C++ Programming
    Replies: 3
    Last Post: 05-18-2004, 01:17 PM
  4. Some help for a newbie?
    By Ilmater in forum C++ Programming
    Replies: 23
    Last Post: 04-19-2004, 07:44 PM
  5. Newbie Game Develpoers Unite!
    By Telenosis in forum Game Programming
    Replies: 10
    Last Post: 06-22-2002, 02:02 PM