Placing Classes in Separate Files

Aug 5, 2011 at 9:01am
I've got

1
2
3
4
5
6
7
8
9
#include <iostream>
#include "Burrito.h"
using namespace std;

int main()
{
    Burrito bo;
    return 0;
}


1
2
3
4
5
6
7
8
9
10
11
#ifndef BURRITO_H
#define BURRITO_H


class Burrito
{
    public:
        Burrito();
};

#endif // BURRITO_H 


1
2
3
4
5
6
7
8
#include "Burrito.h"
#include <iostream>
using namespace std;

Burrito::Burrito()
{
    cout << "I'm a banana!" << endl;
}


But it drops me an error - undefined reference to `Burrito::Burrito
Aug 5, 2011 at 9:38am
I use VS2010 without errors, the compiler may be the problem it
Aug 5, 2011 at 10:07am
It looks fine to me. Have you tried compiling it without the #ifndef ? For such a small application I don't think you need it.

Rockmachine wrote:
Burrito::Burrito
Sooo hungry!
Aug 5, 2011 at 4:01pm
I apologise for asking such an obvious question, but as I can't see a problem with the code...

Did you remember to add the new C++ file to your project?

The message sounds like the linker is complaining that it could't find the constructor.
Last edited on Aug 8, 2011 at 2:07pm
Aug 8, 2011 at 6:35am
I saw burrito and felt compelled to respond here. Have you been watching Bucky's tutorials??
Aug 8, 2011 at 7:14am
I'm with andywestken on this one. That's the only thing I can think of...
Topic archived. No new replies allowed.