我目前正在使用Code :: Blocks IDE 10.04进行简单的类示例。在创建新类时遇到undefined reference to myClass::myClass()
错误。帮我弄清楚错误。
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;
}