| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 561 人关注过本帖
标题:[求助]一个关于动态链接库的问题
只看楼主 加入收藏
neufcl
Rank: 1
等 级:新手上路
帖 子:68
专家分:0
注 册:2007-10-23
收藏
 问题点数:0 回复次数:4 
[求助]一个关于动态链接库的问题

//point.h
#ifndef POINT_H
#define POINT_H
#ifdef DLL_FILE
class _declspec(dllexport)point
#else
class _declspec(dllimport)point
#endif
{
public:
point(float a=0,float b=0);
void getPoint(float&,float&);
private:
float x;
float y;

};
#endif

//point.cpp
#ifndef DLL_FILE
#define DLL_FILE
#endif
#include"stdafx.h"
#include "point.h"
point::point(float a,float b)
{
x=a;
y=b;
}
void point::getPoint(float &a,float &b)
{
a=x;
b=y;
}

//circle.h
#ifndef CIRCLE_H
#define CIRCLE_H
#include "point.h"
#ifdef DLL_FILE
class _declspec(dllexport)circle
#else
class _declspec(dllimport)circle
#endif
{
public:
circle();
void setCentre(const point&);
void setRadius(const float &);
float getArea();
// ~circle(){};
private:
point centre;
float radius;
};
#endif

//circle.cpp
#ifndef DLL_FILE
#define DLL_FILE
#endif
#include "stdafx.h"
#include "circle.h"

const PI=3.1415926;
circle::circle()
{
centre=point(0,0);
radius=0;
}
float circle::getArea()
{
return PI*radius*radius;
}
void circle::setCentre(const point &p)
{
centre=p;
}
void circle::setRadius(const float &r)
{
radius=r;
}

//主程序
// dllClassCall.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "point.h"
#include "circle.h"
#pragma comment(lib,"dllClassTest.lib");
#include<iostream>
using namespace std;

int main(int argc, char* argv[])
{
point p;
float x,y;
p.getPoint(x,y);
cout<<x<<endl<<y<<endl;
circle c;
/* float r=1;
c.setCentre(p);
c.setRadius(r);
cout<<c.getArea()<<endl;*/
cin.get();
return 0;
}

当主程序中没有circle的对象时,程序正确运行。但是当有circle对象时出现无法定位程序输入点的错误
请高手指点!!!!!!

[此贴子已经被作者于2007-10-28 13:30:51编辑过]

搜索更多相关主题的帖子: 动态链接库 
2007-10-28 13:30
neufcl
Rank: 1
等 级:新手上路
帖 子:68
专家分:0
注 册:2007-10-23
收藏
得分:0 
高手大侠们快快现身吧

学好C++
2007-10-28 13:44
neufcl
Rank: 1
等 级:新手上路
帖 子:68
专家分:0
注 册:2007-10-23
收藏
得分:0 
哪位好心的大哥,帮帮小弟呗

学好C++
2007-10-28 14:00
neufcl
Rank: 1
等 级:新手上路
帖 子:68
专家分:0
注 册:2007-10-23
收藏
得分:0 
高手都去哪儿了。周末出去玩了?

学好C++
2007-10-28 14:48
Janlex
Rank: 3Rank: 3
等 级:新手上路
威 望:6
帖 子:303
专家分:0
注 册:2006-9-12
收藏
得分:0 
问题一
const double PI=3.1415926;

问题二
#pragma comment(lib,"dllClassTest.lib") //去掉';'符号

-------但这并非主要问题.

观注中

★★★★★欢迎光临我的博客 ★★★★★
http://www.
2007-10-29 22:20
快速回复:[求助]一个关于动态链接库的问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014852 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved