Thread: help with errors...

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    30

    help with errors...

    Im getting a lot of errors in this program and i don't know why? also, why did these errors create a problem?

    a) line 5 parse error before `{'
    b) line 10 parse error bofore `int'
    c) `month' was not declarde in the scope
    d) ANSI C++ forbids declaration `setNum2' with no type
    e) line 15 ANSI C++ forbids declaration `aYear' with no type
    f) line 15 `year' was not declared in this scope
    g) line 16 parse error before `}'
    h) line 18 implicit declaration of function `int getNum1(...)'
    i) line 18 implicit declaration of function `int getNum2(...)'
    j) line 19 parse error before `<'
    k) line 26 variable `class Date HeidiKlum' has initializer but incomplete type
    l) line 29 parse error before `<'
    and finally..............
    M!) line 31 parse error before `<'

    Thanks for the help!
    -----------------------------------------------------------------------------------
    [Code:]
    -----------------------------------------------------------------------------------

    *******LOOK BELOW FOR NEW CODE *********
    Last edited by Gamma; 04-13-2002 at 04:54 PM.

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    30
    ATTN: all problems solved except for h and i, and one new problem, on line 29 no matching function for call to `Date::getNum ()'

  3. #3
    Registered User
    Join Date
    Apr 2002
    Posts
    200
    post the updated code so we dont have to go through and mess with the errors you've solved, please. BTW, is everything correct in "pair.h"?

    PS: Thanks for trying to use code tags! But you use them like this:

    [codep]

    code goes here...

    [/codep]

    except take the p out-I put it in there so it wouldnt get parsed.
    Good Luck!
    I go to encounter for the millionth time the reality of experience and to forge in the smithy of my soul the uncreated conscience of my race.

    Windows XP consists of 32 bit extensions and a graphical shell for a 16 bit patch to an 8 bit operating system originally coded for a 4 bit microprocessor, written by a 2 bit company, that can't stand 1 bit of competition.

  4. #4
    Registered User
    Join Date
    Apr 2002
    Posts
    30
    [Code for main proggie:]
    Code:
    #include <string.h>
    #include <iostream.h>
    #include "pair.h"
    
    class Date : public Pair {
          public:
                 int getYear () {
                     return aYear;
                 }
                 Date (int day, int month, int year) {
                 // set attributes of pair
                 setNum1 (day);
                 setNum2 (month);
                 // set new attribute
                 aYear = year;
                 }
                 void output () {
                      cout << getNum1 () << "." << getNum2 () << "."
                           << aYear << endl;
                      }
                 private:
                         int aYear; // the year
                 };
    
    main () {
         Date HeidiKlum (4,8,1976); // the constructor
         HeidiKlum.output ();
         cout << "the contents of aYear is for Heidi is" << " "
              << HeidiKlum.getYear () << endl;
    };
    [Code for pair.h file:]
    Code:
    // pair.h file
    #ifndef PAIR_H__
    #define PAIR_H__
    
    class Pair {
          public:
    		Pair (int num1, int num2);
    		Pair ();
    		void output ();
    		void setNum1 (int num);
    		void setNum2 (int num);
    
          private:
                  	int aNum1;
                  	int aNum2;
          };
    
    #endif
    Last edited by Gamma; 04-13-2002 at 04:56 PM.

  5. #5
    Registered User
    Join Date
    Apr 2002
    Posts
    200
    it appears as if you haven't declared or defined getNum1 or getNum2 anywhere in your code, but then again I'm getting kind of blind...
    I go to encounter for the millionth time the reality of experience and to forge in the smithy of my soul the uncreated conscience of my race.

    Windows XP consists of 32 bit extensions and a graphical shell for a 16 bit patch to an 8 bit operating system originally coded for a 4 bit microprocessor, written by a 2 bit company, that can't stand 1 bit of competition.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. global namespace errors
    By stubaan in forum C++ Programming
    Replies: 9
    Last Post: 04-02-2008, 03:11 PM
  2. Ten Errors
    By AverageSoftware in forum Contests Board
    Replies: 0
    Last Post: 07-20-2007, 10:50 AM
  3. Unknown Errors in simple program
    By neandrake in forum C++ Programming
    Replies: 16
    Last Post: 04-06-2004, 02:57 PM
  4. Stupid compiler errors
    By ChrisEacrett in forum C++ Programming
    Replies: 9
    Last Post: 11-30-2003, 05:44 PM
  5. errors in class(urgent)
    By ayesha in forum C++ Programming
    Replies: 2
    Last Post: 11-10-2001, 06:51 PM