Hi,
I am trying to create a very basic class but keep getting an undefined reference error. I am confused about what this error means, and when searching online, I was unable to find any complete answer. Any help would be greatly appreciated. Here is my code:
Code:
//My main/driver
#include <iostream>
#include "Example.h"
using std::cout;
using std::endl;
int main() {
cout << "THIS IS AN EXAMPLE" << endl;
Example sample;
sample.print();
return 0;
}
//My example class, i just want it to print out something.
#include <iostream>
using std::cout;
using std::endl;
class Example
{
void print() {
cout << "THIS IS NOW PRINTING IN THE CLASS" << endl;
}
};
//My header file:
#include <iostream>
using std::cout;
using std::endl;
class Example
{
public:
void println();
};
I am compiling on unix by typing g++ -o main main.cpp and as I mentioned before, it returns an undefined reference error.
Thanks for any help anyone can give me.