-
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 *********
-
ATTN: all problems solved except for h and i, and one new problem, on line 29 no matching function for call to `Date::getNum ()'
-
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!
-
[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
-
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...