我目前正在使用 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
我的类.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;
}