代码::块10.05对函数的未定义引用 [英] Code::Blocks 10.05 Undefined reference to function

查看:78
本文介绍了代码::块10.05对函数的未定义引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用Code :: Blocks IDE 10.04进行简单的类示例。创建新类时,遇到对myClass :: myClass()的未定义引用。

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:

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:

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:

sinpleClass.cpp:

#include<E:\IOE\VII\Elective-DM\Assignment 2\myClass.h>
int main()
{
    myClass myClassObj;
    myClassObj.showMessage();
    return 0;
}


推荐答案

发生此错误是由于链接错误。后来我创建了新项目(根据克里斯评论上面的问题),并向其添加类,项目即可成功编译。

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.

这篇关于代码::块10.05对函数的未定义引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆