| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 460 人关注过本帖
标题:[求助]最后一个错误怎么也改不过来
取消只看楼主 加入收藏
白衣吹水
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2007-4-10
收藏
 问题点数:0 回复次数:0 
[求助]最后一个错误怎么也改不过来

错误如下:
d:\My Documents\Visual Studio Projects\563\256\200431046.cpp(99): error C2440: “初始化” : 无法从“const char *”转换为“CLeapYear”

我的程序如下,不知道怎么改了.其他地方都改了就是这样改不了.实在是想不出来,请教各位高手了.

#include <iostream>
#include <string.h>
using namespace std;

struct Syear
{
int start,end;
};
//10

class CLeapYear
{
private:
Syear time;
int r_year;
int *p_leap_year;
int *p_time_name;
static int total_year_object;
static int no_of_leap_year;

public://20
CLeapYear(const Syear &r_time_val,char time_name[]);
int setyear();
bool isLeap();
int findLeapYear();
void print();
~CLeapYear()
{
cout<<"destructing leap_year"<<this->p_leap_year<<endl;
delete p_leap_year;
delete p_time_name;//30
}
};

CLeapYear::CLeapYear(const Syear &r_time_val,char time_name[])
{
cout<<"Constructor with 2 parameters is called"<<endl;
time=r_time_val;
p_time_name=new int[strlen(time_name)+1];
if(time_name==NULL)
exit(1);//40
}

int CLeapYear::setyear()
{
char ch;
ch=cin.get();
cout<<"请选择:输入1,判断将要输入的某个年份是否闰年;输入2,输入起始年份列出期间的所有闰年.\n";
if(ch==1)
cout<<"请输入一个要判断的年份";
cin>>r_year;//50

if(ch==2)
cout<<"请输入起始年份";
cin>>time.start>>time.end;
}


bool CLeapYear::isLeap()
{//60
if(r_year%4 == 0 && r_year%100 != 0)
return true;
if(r_year%400 == 0)
return true;

return false;
}


int CLeapYear::findLeapYear()//70
{
int year;
for(year=time.start;year<=time.end;year++)
{
if((year%4 == 0 && year%100 != 0) || year%400 == 0)
no_of_leap_year++;
p_leap_year=new int[no_of_leap_year+1];
*p_leap_year=year;

return *p_leap_year;//80
}
}

void CLeapYear::print()
{
cout<<"The leap year from"<<time.start<<"to"<<time.end<<"are"<<p_leap_year++;
cout<<endl;
}

//90

int CLeapYear::total_year_object=0;
int CLeapYear::no_of_leap_year=0;


void main()
{
Syear time1={1904,2007},time2={1876,1956};
CLeapYear leapyear1(time1,"first"),leapyear2=(time2,"second");
//100
leapyear1.findLeapYear();
leapyear1.print();

leapyear2.findLeapYear();
leapyear2.print();
}

搜索更多相关主题的帖子: Documents private include start 
2007-05-10 20:55
快速回复:[求助]最后一个错误怎么也改不过来
数据加载中...
 
   



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

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