Error: Undefined reference to class

I've just begun learning C++ through TheNewBoston tutorials, and I cannot get passed this particular project because I can't identify the problem. It says,"undefined reference to Dorkclass::Dorkclass from the main.cpp.

Main.cpp
1
2
3
4
5
6
7
8
9
10
  #include <iostream>
#include "Dorklass.h"

using namespace std;

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


Dorkclass.h
1
2
3
4
5
6
7
8
9
10
11
12
#ifndef DORKCLASS_H
#define DORKCLASS_H


class Dorkclass
{
    public:
        Dorkclass();

};

#endif // DORKCLASS_H 


Dorkclass.cpp
1
2
3
4
5
6
7
8
#include "Dorkclass.h"
#include <iostream>

using namespace std;
Dorkclass::Dorkclass()
{
  cout << "Darn these errors." << endl;
}


Also, yes, I made sure that I used a console application and included all the files in the build and run.
closed account (L6b7X9L8)
http://www.cplusplus.com/doc/tutorial/classes/

Maybe try in your main to add the parenthesis -> () to the bo.

1
2
3
4
5
int main()
{
    Dorkclass bo();
    return 0;
}
Last edited on
Wow, this is embarrassing, but I've already found the solution to my problem. For some reason, I had to change my compiler settings to use C++11 ISO standards. Everything is running fine, now.
closed account (L6b7X9L8)
Yes I was about to say scratch what I said, your code compiles fine for me. :)
Topic archived. No new replies allowed.