0

As explained above i have a problem making classes.I am getting this error:

C:\Users\USER\AppData\Local\Temp\ccj3stv6.o main.cpp:(.text+0x15): undefined reference to 'plate::plate()'

C:\Users\USER\AppData\Local\Temp\ccj3stv6.o main.cpp:(.text+0x21): undefined reference to 'plate::SayHello()'

E:\c++\proje16\collect2.exe [Error] ld returned 1 exit status

main.cpp

#include <iostream>
#include "plate.h"

using namespace std;

int main () {
    plate pobj;
    pobj.SayHello();
}

plate.cpp

#include <iostream>
#include "plate.h"

using namespace std;


plate::plate(){
}

void plate::SayHello () {
    cout << "hello";
}

plate.h

#ifndef PLATE_H
#define PLATE_H

class plate
{
    public:
        plate();
        void SayHello();
};

#endif

error,main.cpp,plate.cpp,plate.h combined as an image

using #include "plate.cpp" instead of #include "plate.h" helps but i am not sure if thats a good fix or not.

I am using dev-c++ 5.11.I am not that experienced in coding.I done some research before posting this question but couldn't solve my problem.

  • 2
    Do you have the `plate` files included as part of your project, so that they're compiled and linked together with your main? – Kdawg Jul 29 '17 at 14:48
  • 1
    Also see [this](https://stackoverflow.com/questions/15579172/undefined-reference-to-class-constructor-including-cpp-file-fixes) similar issue. – Chostakovitch Jul 29 '17 at 14:52
  • Your constructor is useless. –  Jul 29 '17 at 15:24
  • i didnt do anything but it is working now :P do i have to restart my computer after making a new class or something? @manni66 is that an issue? – bbs_samuray Jul 29 '17 at 16:48
  • It's a readability issue. –  Jul 29 '17 at 17:40

0 Answers0