Your header file Hash.h
declares “what class hash
should look like”, but not its implementation, which is (presumably) in some other source file we’ll call Hash.cpp
. By including the header in your main file, the compiler is informed of the description of class Hash
when compiling the file, but not how class Hash
actually works. When the linker tries to create the entire program, it then complains that the implementation (toHash::insert(int, char)
) cannot be found.
The solution is to link all the files together when creating the actual program binary. When using the g++ frontend, you can do this by specifying all the source files together on the command line. For example:
g++ -o main Hash.cpp main.cpp
will create the main program called “main”.
Related Posts:
- What are the differences between a pointer variable and a reference variable in C++?
- c++ “Incomplete type not allowed” error accessing class reference information (Circular dependency with forward declaration)
- Undefined Symbols for architecture x86_64: Compiling problems
- What does `*&` in a function declaration mean?
- Pass a vector by reference C++
- Difference between const reference and normal parameter
- Is the practice of returning a C++ reference variable evil?
- initial value of reference to non-const must be an lvalue
- Error: No instance of constructor matches the argument list
- c++ “Incomplete type not allowed” error accessing class reference information (Circular dependency with forward declaration)
- Base class undefined
- error: invalid initialization of non-const reference of type ‘int&’ from an rvalue of type ‘int’
- Reference to non-static member function must be called
- C++ Return value, reference, const reference
- C++ pass an array by reference
- How to create a vector of class objects in C++?
- Is null reference possible?
- Why can’t I make a vector of references?
- Is C++ Array passed by reference or by pointer?
- C++ convert from 1 char to string?
- Pause Console in C++ program
- What is the easiest way to initialize a std::vector with hardcoded elements?
- Passing an array by reference
- What does int argc, char *argv[] mean?
- Meaning of = delete after function declaration
- Using NULL in C++?
- C++ Error: undefined reference to `main’
- 1.#QNAN error C++
- What is the array form of ‘delete’?
- Error: Expression must have integral or unscoped enum type
- Use new operator to initialise an array
- Remove secure warnings (_CRT_SECURE_NO_WARNINGS) from projects by default in Visual Studio
- “No viable overloaded ‘=’ ” why?
- Check if a string contains a string in C++
- Efficient way to return a std::vector in c++
- What is an ‘undeclared identifier’ error and how do I fix it?
- Initializing a two dimensional std::vector
- What does “<<" and ">>” mean in C++ for cout/cin?
- C ++ error: a expected initializer before [function name]
- invalid new-expression of abstract class type
- std::string to char*
- Does the ‘mutable’ keyword have any purpose other than allowing the variable to be modified by a const function?
- SDL2.DLL missing
- no default constructor exists for class
- Press Enter to Continue
- How to trim a std::string?
- Parsing a comma-delimited std::string
- Random number c++ in some range
- “g++” is not recognized as an internal or external command, MinGW
- Compiling a C++ program with gcc
- Fatal error: ‘stdafx.h’ file not found
- How do I add the MinGW bin directory to my system path?
- What’s the syntax for declaring an array of function pointers without using a separate typedef?
- What is the difference between const_iterator and non-const iterator in the C++ STL?
- Sorting Linked List C++ with pointers
- Get Unix timestamp with C++
- Class prototyping
- How to dynamically allocate an array of pointers in C++?
- How do I compile C++ to JavaScript in a browser?
- Is the sizeof(some pointer) always equal to four?
- How do you initialise a dynamic array in C++?
- What are the distinctions between the various symbols (*,&, etc) combined with parameters?
- Reading from .txt file into two dimensional array in c++
- C++ Error ‘nullptr was not declared in this scope’ in Eclipse IDE
- C++ Simple hangman game
- “The system cannot find the file specified” when running C++ program
- Remove First and Last Character C++
- C++ Convert string (or char*) to wstring (or wchar_t*)
- Program received signal SIGSEGV, Segmentation fault
- Integer to hex string in C++
- Comparison of C++ unit test frameworks
- What is the difference between .cc and .cpp file suffix?
- C++ error: object of abstract class type is not allowed: pure virtual function has no overrider
- Correct way to work with vector of arrays
- What’s the difference between nexti and stepi in gdb?
- How to get current time in milliseconds?
- Fastest way to Convert String to Binary?
- Reading data from file into an array
- LINK : fatal error LNK1561: entry point must be defined ERROR IN VC++
- Trying to use int in getline
- c++ error c2015: too many characters in constant
- Splitting a C++ std::string using tokens, e.g. “;”
- Py_Initialize fails – unable to load the file system codec
- error LNK2019: unresolved external symbol “” referenced in function
- What is the job of autogen.sh when building a c++ package on Linux
- Using G++ to compile multiple .cpp and .h files
- LPCSTR, LPCTSTR and LPTSTR
- How to do std::string indexof in C++ that returns index of matching string?
- variable or field declared void
- Invalid conversion from ‘char’ to ‘const char *’
- How do I deal with “signed/unsigned mismatch” warnings (C4018)?
- Creating folders in C++
- Unrecognizable template declaration/definition
- What does “-Wall” in “g++ -Wall test.cpp -o test” do?
- C++ equivalent of StringBuffer/StringBuilder?
- heap corruption detected | C++
- Update g++ but still old version
- module unsafe for SAFESEH image C++
- Why are there two different getline() functions (if indeed there are)?
- Whats the difference between UInt8 and uint8_t