作业遇到有关问题,求教~
发布时间:2011-06-23 14:41:28 文章来源:www.iduyao.cn 采编人员:星星草
作业遇到问题,求教~~
作业叫创建一个C++类库不使用预编译头,输入代码如下:
Mandel.h
# using<System.Drawing.dll>
using namespace System::Drawing;
#using <mscorlib.dll>
public ref class Mandel
{
public:
int width, height; /* screen size */
long double midx, midy; /* image posn */
long double sizex, sizey; /* image size */
int Color(int ix, int iy);
};
Mandel.cpp
#include "Mandel.h"
int Mandel::Color(int ix, int iy)
{
unsigned iter = 0;
long double x, y, x2, y2, temp;
long double cy = midy + (2.0 * iy /height - 1.0) * sizey;
long double cx = midx + (2.0 * ix /width - 1.0) * sizex;
x = y = x2 = y2 = 0.0;
while( iter < 256 && ( x2 + y2 ) < 4.0) {
temp = x2 - y2 + cx;
y = 2 * x * y + cy;
x = temp;
x2 = x * x;
y2 = y * y;
iter++;
}
iter = 256 - iter;
int red = iter * 12 % 256;
int green = iter * 16 % 256;
int blue = iter * 5 % 256;
return Color::FromArgb(red, green, blue);
}
编译结果报错:“error C2440: “return”: 无法从“System::Drawing::Color”转换为“int” ”
我都是按照发的教程一步步做的但是还是有错
本人初学.net,望各位大侠指教!
谢谢
------解决方案--------------------
Color结构没法直接转成int的.调用Color.ToArgb.
------解决方案--------------------
int Mandel::Color(int ix, int iy)
说明返回类型是int型,但你在函数中返回的是Color,而且Color不能隐式转换为int。
可以改为Color Mandel::Color(int ix, int iy)
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。
其他相似内容:
-
c# 类库打包成COM类型库时在vs命令行怎么写
类库打包成COM类型库(在vs命令行中怎么写啊)
路径和格式怎么写?
假如路径是:F:\netTest...
-
int
c#里的int是多少位???????
------解决方案--------------------
int 的值用 31 位来表示,第三十二位为符号位。,其范围从负 2,147,483...
-
求各位大侠帮个忙
做的是一个项目经理评分系统
如何把第一个窗体点击的人的信息显示到第二个窗体里面
------解决方案---------...
-
【asp.net三层怎样入手学习开发?】
我现在搞asp.net都是面向过程的.没有分层
请问怎样做到 mvc ??真正的面向对象的开发??
请问...
-
.net framework 2.0 service pack 1 无法卸载,怎么办
总是提示说安装是发生严重错误,并且说it will affect other application that...
-
Message.Show()的窗体美化
每次弹出的窗口都是那么的单调有没有什么方法能换一下弹出窗体的颜色或者是插一张图片
------解决方...
-
安装vs2010出错,求老师解答!!!
rt
安装vs2010是出错
C:\Users\Administrator\AppData\Local\Temp\SIT32027.tmp\deffactory...
-
怎么做一个转盘出来啊,请教各位大虾
在ASP.NET的页面中怎么弄一个转盘出来啊?
------解决方案--------------------
什么转盘
---...
-
jquery each遍历赋值不上呢
<ul id="myul">
<li><a id="2258">第一个</a></li>
<li><a id="2258">第二个</a></li>
<li>...
-
C#发布问题
这个是怎么回事啊
我在那个debug下面有那个DevExpress.XtraLayout.v9.1.dll这个了 为什么还是报这个错
------解决...