Compiling problem

I don't know why this doesn't compile with me it gives me this error:-
undefined reference to `Sally::Sally()'
undefined reference to `Sally::printCrap()'

Any one could help with this??



This is for "main.cpp"
1
2
3
4
5
6
7
8
9
10
11
#include "Sally.h"
#include <iostream>
using namespace std;

int main()
{
    Sally sallyObject;
    sallyObject.printCrap();

}


This is for "Sally.h"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
 #ifndef SALLY_H
#define SALLY_H


class Sally
{
    public:
        Sally();
        void printCrap();
    protected:
    private:
};

#endif // SALLY_H 


This is for "Sally.cpp"
1
2
3
4
5
6
7
8
9
10
11
#include "Sally.h"
#include <iostream>
using namespace std;

Sally::Sally(){
}

void Sally::printCrap(){
        cout << "sadsagdasjdf" << endl;
}
Did you add Sally.cpp to your project? The error messages are saying it can't find the implementations.


Other than what jib said, you could just slap all the code in one file.
Everything is correct.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <iostream>
using namespace std;

class Sally
{
    public:
        Sally();
        void printCrap();
    protected:
    private:
};

Sally::Sally(){
}

void Sally::printCrap(){
        cout << "sadsagdasjdf" << endl;
}

int main()
{
    Sally sallyObject;
    sallyObject.printCrap();

}
@Poteto I know how to make them in one file I just wanted to try the separation..
@Jib I didn't really get what you mean but if so how to do it? thank you anyway
What compiler/IDE are you using?

You may want to study this link:
http://web.stanford.edu/class/cs106l/course-reader/Ch4_MultiFileAbstractionPreprocessor.pdf
Code::Blocks.. you recommend me a better one?
No, but did you make a project and add all the files to the project?

Try doing a struct instead.... just a suggestion

Classes seem to give me heck when I use them for public purppses
Topic archived. No new replies allowed.