C++ "Classes in separate files"

+3 Cardinal Coog · January 12, 2015
I keep getting the error: "undefined reference to burrito::burrito()"

Here is the main file.

#include <iostream>
#include "burrito.h"

using namespace std;

int main()
    burrito bo;

    return 0;

Here is the Header file:
#ifndef BURRITO_H
#define BURRITO_H

class burrito


#endif // BURRITO_H

Here is the Class file:

#include <iostream>
#include "burrito.h"

using namespace std;

    cout << "I'm getting hungry." << endl;

Post a Reply


- page 2
Oldest  Newest  Rating
0 Alam Khattak · January 12, 2015
+1 Cardinal Coog · January 12, 2015
UGH... Same error in Linux. Using C:B 13.12 Build: Jan 27 2014 - wx2.8.12
(Linux, unicode) - 32 bit

"undefined reference to burrito::burrito()":'(

BTW, the compiler is set to keep the files in the same directory.
+1 Cardinal Coog · January 12, 2015
I'm using C:B 13.12 Build: Dec 27, 2013

I tried re-writing the code and now I'm getting "undefined reference to 'winMain@16'.
In a few minutes I'll try it in my Linux box and let you know what happens. Would still like to know though :(
0 Jay Bennett · January 12, 2015
There is nothing wrong with your code (as far as I can see), and it works. I tested your exact code in both Code::Blocks (version "svn build rev 10035") and Visual Studio 2013. Not sure why you are getting that error, maybe try creating a new project and try the code again?
0 Alf Nohr · January 12, 2015
hmm, it's working for me. What compiler are you using?

Undefined reference error, usually  appears  because the .o file "which gets created from the .cpp file"  do not exist, and your compiler is not able to link them.
  • 1
  • 2



Used in many types of software including music players, video games, and many large scale applications.

Bucky Roberts Administrator