undefined reference to class

0 Adeel Zahid · July 5, 2014
I am trying to access the plum class but code blocks gives error that is undefined reference to `plum::plum()......kindly help


Error
=== Build: Debug in pointers to access class (compiler: GNU GCC Compiler) ===
In function main();
D:\C++\pointers to access class\main.cpp7undefined reference to `plum::plum()'
D:\C++\pointers to access class\main.cpp8undefined reference to `plum::print1()'
=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 3 second(s)) ===




main.cpp is
#include <iostream>
#include "plum.h"
using namespace std;


int main()
{
   plum PO;
   PO.print1();
}


plum.cpp is
#include "plum.h"
#include <iostream>
using namespace std;


plum::plum()
{


}


void plum::print1(){
cout << "access plum class using object" << endl;
}


void plum::print2(){
cout << "access plum class using pointers" << endl;
}


plum.h is
#ifndef PLUM_H
#define PLUM_H




class plum
{
    public:
        plum();
        void print1();
        void print2();
};


#endif // PLUM_H

Post a Reply

Replies

Oldest  Newest  Rating
+1 Mathias Frits Rørvik · July 5, 2014
Please edit your post, press the "code" button and copy paste your code into the box that appears. It will make the code easier to read, and more people will be willing to help you. 
  • 1

C++

103,797 followers
About

Used in many types of software including music players, video games, and many large scale applications.

Links
Moderators
Bucky Roberts Administrator