0
votes

I have created a simple class with header file(.h), class implementation file (.cpp), and main file (.cpp).

There seems to be no errors until I try linking (building) in x-code where I get this error:

Undefined symbols for architecture x86_64:
"bbq::bbq(std::__1::basic_string, std::__1::allocator >, std::__1::basic_string, std::__1::allocator >)", referenced from: _main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)*

And Here is my code:

int main()

{

bbq barbeque ("coleman", "101a");


barbeque.loadCoals(); // print output

The header file:

class bbq
{
private:
string brand, model;



public:
bbq (string brand, string model);
void loadCoals();}

And function definitions:

void bbq::loadCoals()
{

cout<<"Loading Coleman Grill 101A with coals!";

}
1

1 Answers

0
votes

You didn't write bbq::bbq(string brand, string model); implementation in the .cpp file.

You have to implement it:

bbq::bbq(string brand, string model) {
   this->brand = brand;
   this->model = model;
}