OK so I am going through a c++ tutorial on youtube as I am a relatively new programmer. I am trying to learn how to use header files and such when creating classes. In this tutorial we learn how to use the arrow member selection operator.
https://www.youtube.com/watch?v=2RP4f9beidc&list=PLAE85DE8440AA6B83&index=42
I am not using codeblocks which is the IDE he is using. I am writing my code on gedit and compiling and running it using Cygwin.
Any help would be greatly appreciated!
Here is the simple code:
Main.cpp
#include <iostream>
#include "Sally.h"
using namespace std;
int main(){
Sally sallyObject;
Sally *sallyPointer = &sallyObject;
sallyObject.printCrap();
sallyPointer->printCrap();
}
Sally.cpp
#include "Sally.h"
#include <iostream>
using namespace std;
Sally::Sally()
{
}
void Sally::printCrap(){
cout << "did someone say steak?" << endl;
}
Sally.h
#ifndef SALLY_H
#define SALLY_H
#include <iostream>
class Sally
{
public:
Sally();
void printCrap();
protected:
private:
};
#endif // SALLY_H
Error code:
/tmp/ccfOEJJF.o:Main.cpp:(.text+0x15): undefined reference to Sally::Sally()'
/tmp/ccfOEJJF.o:Main.cpp:(.text+0x15): relocation truncated to fit: R_X86_64_PC32 against undefined symbol
Sally::Sally()'
/tmp/ccfOEJJF.o:Main.cpp:(.text+0x29): undefined reference to Sally::printCrap()'
/tmp/ccfOEJJF.o:Main.cpp:(.text+0x29): relocation truncated to fit: R_X86_64_PC32 against undefined symbol
Sally::printCrap()'
/tmp/ccfOEJJF.o:Main.cpp:(.text+0x35): undefined reference to Sally::printCrap()'
/tmp/ccfOEJJF.o:Main.cpp:(.text+0x35): relocation truncated to fit: R_X86_64_PC32 against undefined symbol
Sally::printCrap()'
collect2: error: ld returned 1 exit status