this makes no sense

Jan 15, 2017 at 8:33pm
I don't understand why this is not working I have been programming for quite some time now and something that SHOULD and normally DOES work is not working I mean it's mind numbing as to why this isn't working,what I missing here normally when you declare an object of a class with the RIGHT parameters it should get creaated but NOPE instead I am getting an error :s


birthday.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

#ifndef BIRTHDAY_H
#define BIRTHDAY_H


class birthday
{
    public:
        birthday(int d,int m,int year);
        void printDate();

    private:

        int day;
        int month;
        int year;
};

#endif // BIRTHDAY_H




birthday.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

#include "birthday.h"
#include <iostream>

using namespace std;

birthday::birthday(int d,int m,int y)
{
     day = d;
     month = m;
     year = y;
}


void birthday::printDate(){

    cout << day << month << year;

}

main

1
2
3
4
5
6
7
8
9
10
11
12
13
14


#include <iostream>

using namespace std;

int main()
{
  birthday birthobj(1,2,1993);


}

Last edited on Jan 15, 2017 at 8:34pm
Jan 15, 2017 at 8:41pm
You need to include birthday.h in the main file as well.
Then it compiles and runs.
Last edited on Jan 15, 2017 at 8:43pm
Jan 15, 2017 at 8:46pm
true that's the problem thanks,I can't believe how rusty I am after taking just 5 months off from programming
Topic archived. No new replies allowed.