I NEED SOME HELP WITH OBJECTS

I would like to know how to call the methods of the class.
I have an object call v which is an array and I don't how to call the methods
of the class. The error is here:
v.readDates(v[a]);

Thank you.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
  #include "Date.h"
  #include <iostream>
  using namespace std;

int main(){
    int a;
    cout << " HOW MANY DATES DO YOU HAVE? " << endl;
    cin >> a;
    Date v[a];
    v.readDates(v[a]);
    v.sortDates(v[a]);
    v.showDates (v[a]);
    return 0;
}
Last edited on
closed account (zybCM4Gy)
Just one...slight...problem...

where have you defined num?

Sorry!! it must be:
v.readDates(v[a]);
v.sortDates(v[a]);
v.showDates (v[a]);
closed account (zybCM4Gy)
...you're aware that you're going to get errors anyway? Arrays don't take variables in C++ that's a compiler dependent thing. Use vectors instead.

But what does your class look like?
Last edited on
YES OF COURSE: The number format is:
YYYYMMDD EXAMPLE:
20141130
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
void Data::readDates(Data [num]){
        int a_date;
        for (int i=0;i<num;i++){
        cout << "ENTER A DATE:" << endl;
        cin >> a_date;
        int day=v[i].days(a_date);
        int year=v[i].years(a_date);
        int month=v[i].months(a_date);
        while (!esValida(any,mes,dia)){
            cin >> a_date;
            day=v[i].days(a_date);
            year=v[i].years(a_date);
            month=v[i].months(a_date);
        }
    }
}
Last edited on
Topic archived. No new replies allowed.