Hello everybody!
Recently while i was experimenting with some code written in c++ i noticed something that confused me a bit. In that code i had to deal with 2 structs :
struct date
{
string day;
int month;
int dday;
int year; };
and the other struct
struct note
{
date d;
string notice; };
I noticed that when i was passing in a function i built, an instance of note struct as a pointer parameter my program kept crashing continuously, although compiler wasn't complaining. To make myself clear :
void myFunction(note* n, ...other parameters...)
{
cout << n->d.day << endl;
cout << n->d.month << endl;
etc...
}
I'm sure that my program crashed because of that piece of code
n->d.day
i'm sure because i tested it in debug mode.
When i wrote my function differently i had no problem running my program :
void myFunction(note& n, ..other parameters...)
{
cout << n.d.day << endl;
cout << n.d.month << endl;
etc...
}
Has anyone got an idea why the pointer parameter and the arrow
caused that problem? Looking forward to reading your ideas and thoughts...Thank you in advance for your time...
vanalex