// birthday.cpp
#include "birthday.h"
birthday::birthday(int m, int d, int y)
{
month = m;
day = d;
year = y;
}
void birthday::printdate() {
cout << month << "/" << day << "/" << year << endl;
}
C:\people.h|9|error: 'Birthday' has not been declared|
C:\main.cpp||In function 'int main()':|
C:\main.cpp|9|error: 'bo' was not declared in this scope|
C:\main.cpp|10|error: 'class people' has no member named 'printdate'|
I'm a bit in the dark here too but it should be birthday, not Birthday in your main.
Also make sure you have bo as the birthday object not bob, better still make it xyz
1 2 3 4 5 6 7 8
int main()
{
birthday xyz(6, 7, 1990);
people me("Bob", xyz);
me.printinfo();
cout << "Finished";
}
I changed my header files to the #pragma once and added the using std parts. But I did not change my main file and it ran fine. here is my main file that is working:
I think i understand. What is #pragma once?
And with the header files, the .h didnt know to use the "standard" functions like cpp files. you would think the header files would not need that info
The cpp files don't 'know' about the header file unless you tell them.
It's the same with any of the #includes - essentially they are instructions to the linker exactly the same way cout means zip unless you #include <iostream> where all the meaning is.
Let's face it though, at least the linker/compiler error reporting tells you what it can't work out.
#pragma once is a directive to only read/link that class once.