2

I'm currently doing simple class example using Code::Blocks IDE 10.04. On creating new class I encounter undefined reference to myClass::myClass() error. Help me on figuring the error.

myclass.h:

#ifndef MYCLASS_H
#define MYCLASS_H
#include<string>
#include<iostream>
using namespace std;
class myClass
{
    public:
        myClass();
     void showMessage();
        virtual ~myClass();
    protected:
    private:
    string myString;
    int integer;
};

#endif // MYCLASS_H

myclass.cpp:

#include "E:\IOE\VII\Elective-DM\Assignment 2\myClass.h"

myClass::myClass()
{
    //ctor
}

myClass::~myClass()
{
    //dtor
}
void myClass::showMessage()
{
    cout<<"Enter the number ";
    cin>>integer;
    cout<<"Enter the String ";
    cin>>myString;
    cout<<"\nInterger you enter is :-"<<integer<<" and String you enter is "<<myString<<endl;

}

sinpleClass.cpp:

#include<E:\IOE\VII\Elective-DM\Assignment 2\myClass.h>
int main()
{
    myClass myClassObj;
    myClassObj.showMessage();
    return 0;
}
Joseph Mansfield
  • 104,685
  • 19
  • 232
  • 315
Lionel
  • 604
  • 9
  • 25

1 Answers1

3

This error is occurs due to the linking error.Later I create new project (according to chris comment above on question) and add class to it the project compile successfully.

Community
  • 1
  • 1
Lionel
  • 604
  • 9
  • 25