B
Ben
I am having trouble calling functions in another file.. Lets look at
the scenario below:
File xyz.cc: (I have both xyz.h and xyz.cc, for simplicity I've
avoided xyz.h)
------------
struct xyz {
int x, y, z;
};
xyz readxyz (fstream& inFile) {
xyz g;
g.x = 4;
g.y = 3;
g.z = 6;
return g;
}
// end File: xyz.cc
File abc.cc: (I have both abc.h and abc.cc, for simplicity I've
avoided abc.h)
------------
struct abc {
int a;
xyz b; // b of type xyz (struct)
int c;
};
abc readabc (fstream& inFile) {
abc h;
h.a = 5;
h.b = readxyz(inFile);
h.c = 10;
return h;
}
int main() {
.......
fstream inFile;
inFile.open(...);
.......
.......
abc val = readabc(inFile);
.......
.......
return 0;
}
// end File: abc.cc
when i compile using g++ (gcc version 3.2), i get errors like this:
/tmp/ccqCIxjA.o: In function `readabc(std::basic_ifstream<char,
std::char_traits<char> >&)':
/tmp/ccqCIxjA.o(.text+0xb8): undefined reference to
`readxyz(std::basic_ifstream<char, std::char_traits<char> >&)'
i'm not sure what it means... any suggestions?? i've also tried
putting readabc() and readxyz() inside the struct but i'm getting
similar error...
any help will be highly appreciated!
Thanx
Ben
the scenario below:
File xyz.cc: (I have both xyz.h and xyz.cc, for simplicity I've
avoided xyz.h)
------------
struct xyz {
int x, y, z;
};
xyz readxyz (fstream& inFile) {
xyz g;
g.x = 4;
g.y = 3;
g.z = 6;
return g;
}
// end File: xyz.cc
File abc.cc: (I have both abc.h and abc.cc, for simplicity I've
avoided abc.h)
------------
struct abc {
int a;
xyz b; // b of type xyz (struct)
int c;
};
abc readabc (fstream& inFile) {
abc h;
h.a = 5;
h.b = readxyz(inFile);
h.c = 10;
return h;
}
int main() {
.......
fstream inFile;
inFile.open(...);
.......
.......
abc val = readabc(inFile);
.......
.......
return 0;
}
// end File: abc.cc
when i compile using g++ (gcc version 3.2), i get errors like this:
/tmp/ccqCIxjA.o: In function `readabc(std::basic_ifstream<char,
std::char_traits<char> >&)':
/tmp/ccqCIxjA.o(.text+0xb8): undefined reference to
`readxyz(std::basic_ifstream<char, std::char_traits<char> >&)'
i'm not sure what it means... any suggestions?? i've also tried
putting readabc() and readxyz() inside the struct but i'm getting
similar error...
any help will be highly appreciated!
Thanx
Ben