Knowee
Questions
Features
Study Tools

/tmp/cc457SXT.o: In function `main':mainc-5557-1709993200.1203434.cpp:(.text+0x1f): undefined reference to `Bank::Bank()'collect2: error: ld returned 1 exit status

Question

/tmp/cc457SXT.o: In function main':mainc-5557-1709993200.1203434.cpp:(.text+0x1f): undefined reference to Bank::Bank()'collect2: error: ld returned 1 exit status

🧐 Not the exact question you are looking for?Go ask a question

Solution

The error message you're seeing is a linker error coming from the g++ compiler. It's saying that it can't find the definition for the constructor of a Bank class.

Here are the steps to solve this issue:

  1. Check your Bank class definition. Make sure you have defined a constructor for it. It should look something like this:
class Bank {
public:
    Bank(); // Constructor declaration
    // Other members...
};
  1. Make sure you have implemented the constructor in your .cpp file. The implementation should look something like this:
Bank::Bank() {
    // Constructor implementation
}
  1. If you have multiple .cpp files, make sure you are linking them correctly. If you're using g++, the command should look something like this:
g++ main.cpp bank.cpp -o output

In this command, main.cpp and bank.cpp are the .cpp files you're trying to compile and link, and output is the name of the output file.

  1. If you have declared and defined the constructor correctly, and you're still getting the error, it might be because the linker is not looking at the right place for the Bank class definition. Make sure the Bank class definition is in a file that's included in the compilation.

  2. If you're using a build system or an IDE, make sure it's configured correctly to include all the necessary .cpp files in the build.

This problem has been solved

Similar Questions

/usr/bin/ld: /tmp/ccBNWlLn.o: in function `main':main.c:(.text+0x87): undefined reference to `sqrt'/usr/bin/ld: main.c:(.text+0xb2): undefined reference to `sqrt'/usr/bin/ld: main.c:(.text+0xd1): undefined reference to `sqrt'collect2: error: ld returned 1 exit status

home/ubuntu/Main.cpp: In function ‘int main()’:/home/ubuntu/Main.cpp:60:13: error: ‘exit’ was not declared in this scope 60 | exit(0); | ^~~~

Line 6: Char 16: runtime error: signed integer overflow: 46341 * 46341 cannot be represented in type 'int' (solution.cpp)SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior prog_joined.cpp:15:16

/home/ubuntu/Main.cpp: In function ‘int main()’:/home/ubuntu/Main.cpp:7:35: error: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive] 7 | result = (m >= 6.0 && s >= 50.5) ? "Eligible for Next Round" : (m < 6.0 || s < 50.5) ? | ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | const char* 8 | "Not Eligible" : "Try again..."; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

codes/mainc-5557-1711047180.6225164.cpp: In function 'int main()':codes/mainc-5557-1711047180.6225164.cpp:40:28: error: 'class JobBid' has no member named 'getBidNumber'; did you mean 'bidNumber'? std::cout << lowestBid.getBidNumber() << std::endl; ^~~~~~~~~~~~ bidNumber

1/1

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.