Placing Classes in Separate Files

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
I use VS2010 without errors, the compiler may be the problem it
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!
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
I saw burrito and felt compelled to respond here. Have you been watching Bucky's tutorials??
I'm with andywestken on this one. That's the only thing I can think of...
Topic archived. No new replies allowed.