Having this annoying error.
I keep getting undefined reference to class::method
This is the code that I'd like to do
student::student(){
conscience* c;
unsigned short choice = rand() % 4;
if (choice == 0){
c = new betray();
}
if (choice == 1){
c = new silent();
}
if (choice == 2){
c = new confused();
}
if (choice == 3){
c = new experienced();
}
but I keep getting the error.
This work around works nicely but is not in the main classes constructor but passed by arguments
student::student(conscience* c){
m_Conscience = c;
}
Thanks in advance.
Edit: Exact error: undefined reference to `betray::betray()'
Undefined reference can mean one of the following:
I suggest you check if you are linking against betray.o. Check your makefile. If you don't have a makefile, I encourage you to write one.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.