error C2228: “.i_nowp”的左边必须有类/结构/联合?????????

laihuahua 2008-12-15 05:14:58
#include "SimpleGA.h"
#include "GAUnite.h"
#include "BestSaveGA.h"
#include "AdaptiveGA.h"
#include "time.h"
#include "iostream"
#include "stdlib.h"
using namespace std;
void main(void)
{
int i;
int k;
srand((unsigned)time(NULL));
/*
CSimpleGA sga;
sga.Initial(100,0.001,0.7);
sga.Statistic();
sga.ReportGeneration();
for(i=0;i<100;i++)
{
sga.Generation();
sga.NextGeneration();
sga.Statistic();
cin>>k;
sga.ReportGeneration();
}
sga.FreeSpace();
*/
/*
CBestSaveGA bga;
bga.BegineProc(100,0.0001,0.9,1);
bga.ReportGeneration();
bga.SaveDate("bga09.dat",'r');
for(i=0;i<100;i++)
{
bga.Proc();
// cin>>k;
bga.ReportGeneration();
bga.SaveDate("bga09.dat",'b');
}
bga.SaveCount("bga09count.dat",303);
bga.EndProc();
*/

CAdaptiveGA aga;
char *FileName="C:\\Data\\mdata.txt";
FILE *fp;

fp=fopen(FileName,"a");
aga.BeginProc(100,0.9,0.0001,0.1,0.4,4);
aga.ReportGeneration();
aga.SaveDate("ad09.dat",'r');

while(1)
{

aga.Proc();

aga.ReportGeneration();

aga.SaveDate("ad09.dat",'b');
if(aga.m_count>=200)
{
//
//
fprintf(fp," %d \n",pool.i_nowp);
break;
}
}
aga.SaveCount("ad09count.dat",303);
aga.EndProc();


}





1>------ 已启动全部重新生成: 项目: FitnessGA, 配置: Debug Win32 ------
1>正在删除项目“FitnessGA”(配置“Debug|Win32”)的中间文件和输出文件
1>正在编译...
1>AdaptiveGA.cpp
1>BestSaveGA.cpp
1>GAUnite.cpp
1>GAWarehouse.cpp
1>main.cpp
1>d:\ga_code\fitnessga\main.cpp(49) : warning C4996: “fopen”被声明为否决的
1> d:\program files\microsoft visual studio 8\vc\include\stdio.h(234) : 参见“fopen”的声明
1> 消息:“This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.”
1>d:\ga_code\fitnessga\main.cpp(66) : error C2065: “pool”: 未声明的标识符
1>d:\ga_code\fitnessga\main.cpp(66) : error C2228: “.i_nowp”的左边必须有类/结构/联合
1> 类型是“'unknown-type'”
1>SimpleGA.cpp
1>d:\ga_code\fitnessga\simplega.cpp(193) : warning C4101: “i”: 未引用的局部变量
1>d:\ga_code\fitnessga\simplega.cpp(275) : warning C4996: “fopen”被声明为否决的
1> d:\program files\microsoft visual studio 8\vc\include\stdio.h(234) : 参见“fopen”的声明
1> 消息:“This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.”
1>d:\ga_code\fitnessga\simplega.cpp(278) : warning C4996: “fopen”被声明为否决的
1> d:\program files\microsoft visual studio 8\vc\include\stdio.h(234) : 参见“fopen”的声明
1> 消息:“This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.”
1>d:\ga_code\fitnessga\simplega.cpp(279) : warning C4996: “fopen”被声明为否决的
1> d:\program files\microsoft visual studio 8\vc\include\stdio.h(234) : 参见“fopen”的声明
1> 消息:“This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.”
1>d:\ga_code\fitnessga\simplega.cpp(293) : warning C4996: “fopen”被声明为否决的
1> d:\program files\microsoft visual studio 8\vc\include\stdio.h(234) : 参见“fopen”的声明
1> 消息:“This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.”
1>正在生成代码...
1>生成日志保存在“file://d:\GA_code\FitnessGA\Debug\BuildLog.htm”
1>FitnessGA - 2 个错误,6 个警告
========== 全部重新生成: 0 已成功, 1 已失败, 0 已跳过 ==========


...全文
1084 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhangzhibiao 2009-07-17
  • 打赏
  • 举报
回复
正解 的确没有声明
bfhtian 2008-12-15
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 xtting_8984313 的回复:]
把pool搞定先,下面的应该就好了。
[/Quote]
up
xiaohou0701 2008-12-15
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 laihuahua 的回复:]
1>d:\ga_code\fitnessga\main.cpp(66) : error C2065: “pool”: 未声明的标识符
1>d:\ga_code\fitnessga\main.cpp(66) : error C2228: “.i_nowp”的左边必须有类/结构/联合
1> 类型是“'unknown-type'”


各位大侠,这个问题怎么解决呢?
[/Quote]


//编译器说的很清楚啊,你的pool是什么?没有声明的标识符.
//例如说,你的pool是一个类MyPool的实例,你应该先写上
MyPool pool;

xtting_8984313 2008-12-15
  • 打赏
  • 举报
回复
把pool搞定先,下面的应该就好了。
nullah 2008-12-15
  • 打赏
  • 举报
回复
upup
jl443960770 2008-12-15
  • 打赏
  • 举报
回复
你的pool变量没有定义,如果是其他文件定义了的话,你至少extern一下啊
wuyu637 2008-12-15
  • 打赏
  • 举报
回复
pool这个是什么东西啊?没有申明,也没有定义。
laihuahua 2008-12-15
  • 打赏
  • 举报
回复
1>d:\ga_code\fitnessga\main.cpp(66) : error C2065: “pool”: 未声明的标识符
1>d:\ga_code\fitnessga\main.cpp(66) : error C2228: “.i_nowp”的左边必须有类/结构/联合
1> 类型是“'unknown-type'”


各位大侠,这个问题怎么解决呢?

64,653

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧