internal/external linkage
I was wandering why this works:
file1.cpp
Code:
#include <iostream>
struct Point {
int a, b;
};
void f(Point *);
int main(int argc, char *argv[])
{
Point a;
f(&a);
return 0;
}
file2.cpp
Code:
struct Point {
int a, b, c;
float z;
};
void f(Point *p)
{
p->a = 5;
p->b = 5;
p->c = 7;
p->z = 25.5;
}
What will happen here?
My compiler doesn't really detects anything.
Edit: the program crashes when i try changing value of z there.
Does this means the programmer has to take care of inconsistent type declarations throughout several files?