社区
C++ 语言
帖子详情
error C2228: left of '.y' must have class/struct/union错误大虾指点?
donkeydonkey
2008-10-30 12:39:25
今天写了个程序编译时出现error C2228: left of '.y' must have class/struct/union错误这个是什么意思?请大虾指点,同种类型的情况我又取编了个小点的程序测试却没有发现错误这是怎么回事??
愁?谢谢同志们啊!
我用的是vs2005
...全文
4119
11
打赏
收藏
error C2228: left of '.y' must have class/struct/union错误大虾指点?
今天写了个程序编译时出现error C2228: left of '.y' must have class/struct/union错误这个是什么意思?请大虾指点,同种类型的情况我又取编了个小点的程序测试却没有发现错误这是怎么回事?? 愁?谢谢同志们啊! 我用的是vs2005
复制链接
扫一扫
分享
转发到动态
举报
AI
作业
写回复
配置赞助广告
用AI写文章
11 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
王小工
2008-10-30
打赏
举报
回复
语法错误.
maying_11
2008-10-30
打赏
举报
回复
.成员操作符号 他的左边必须是类对象,或结构对象.
我是这么认为的.不知道对不对
HelloDan
2008-10-30
打赏
举报
回复
代码片段没有,怎么查啊?
Fighting Horse
2008-10-30
打赏
举报
回复
是不是指针,应该写成->
liubuweiright
2008-10-30
打赏
举报
回复
语法错误.
chihz3800
2008-10-30
打赏
举报
回复
->这个错误我也常犯
arong2004
2008-10-30
打赏
举报
回复
楼上正解!!!!
The_eagles
2008-10-30
打赏
举报
回复
POINT *Points 你这里的Points是个指针啊。
当然是Points[i]->y
donkeydonkey
2008-10-30
打赏
举报
回复
谢谢各位!好像这些都不是给大家看下代码呵
#include "stdafx.h"
#include "conio.h"
#include "math.h"
#include "stdlib.h"
#define MAX_EDGE 500
#define MAX_DATE 500
#define MAX_TRIA 500
long iConvexNum=0;
long DATA_NUM=0;
struct POINT
{ float x;
float y;
};
typedef struct
{ POINT point[3];
}TRIANGLE;
typedef struct
{ POINT EdgePoint1;
POINT EdgePoint2;
}EDGE;
bool TriangleInCircle(float xp, float yp, float x1, float y1, float x2, float y2, float x3, float y3,float *xc, float *yc, float *r)
{
bool Ret;
float eps;
float m1;
float m2;
float mx1;
float mx2;
float my1;
float my2;
float dx;
float dy;
float rsqr;
float drsqr;
eps = 0.000001;
Ret = false;
if (fabs(y1-y2)<eps&&fabs(y2-y3)<eps)
{
return Ret;
}
if ( fabs(y2-y1)<eps )
{
m2=-(x3-x2)/(y3-y2);
mx2=(x2+x3)/2;
my2=(y2+y3)/2;
*xc=(x2+x1)/2;
*yc=m2*(*xc-mx2)+my2;
}
else if ( fabs(y3-y2)<eps )
{
m1=-(x2-x1)/(y2 - y1);
mx1=(x1+x2)/2;
my1=(y1+y2)/2;
*xc=(x3+x2)/2;
*yc= m1 * ((*xc) - mx1) + my1;
}
else
{
m1=-(x2-x1)/(y2-y1);
m2=-(x3-x2)/(y3-y2);
mx1=(x1+x2)/2;
mx2=(x2+x3)/2;
my1=(y1+y2)/2;
my2=(y2+y3)/2;
*xc=(m1*mx1-m2*mx2+my2-my1)/(m1-m2);
*yc=m1*((*xc)-mx1)+my1;
}
dx=x2-(*xc);
dy=y2-(*yc);
rsqr=dx*dx+dy*dy;
*r=sqrt(rsqr);
dx=xp-(*xc);
dy=yp-(*yc);
drsqr=dx*dx+dy*dy;
if (drsqr<= rsqr )
return true;
else
return false;
}
void ConvexHullTriangle(EDGE *Edge,TRIANGLE *Triangle,POINT *Points)
{
long TriNum;
long EdgNum;
for(long i=0;i<iConvexNum;i++)
{
long j=i+1;
long k=i+2;
if(iConvexNum<=3) break;
if(i==iConvexNum-2)
{
k=0;
}
if(i==iConvexNum-1)
{
j=0;
k=1;
}
bool test=true;
for(long r=0;r<iConvexNum;r++)
{
if(r==i||r==j||r==k) continue;
test=TriangleInCircle(Points[r].x ,Points[r].y, Points[i].x, Points[i].y, Points[j].x, Points[j].y, Points[k].x, Points[k].y,float *xc, float *yc, float *r)
if(test==true) break;
}
//如果外接圆不包含凸包上其他点。
if(test==false)
{
//形成三角形,加入三角形数组。
Triangle[TriNum].point[0].x=Points[i].x;
Triangle[TriNum].point[0].y=Points[i].y;
Triangle[TriNum].point[1].x=Points[j].x;
Triangle[TriNum].point[1].y=Points[j].y;
Triangle[TriNum].point[2].x=Points[k].x;
Triangle[TriNum].point[2].y=Points[k].y;
TriNum=TriNum+1;
//加入不重复的边。
if(e==0)
{
Edge[EdgNum+0].EdgePoint1.x=Points[i].x;
Edge[EdgNum+0].EdgePoint1.y=Points[i].y;
Edge[EdgNum+0].EdgePoint2.x=Points[j].x;
Edge[EdgNum+0].EdgePoint2.y=Points[j].y;
Edge[EdgNum+1].EdgePoint1.x=Points[j].x;
Edge[EdgNum+1].EdgePoint1.y=Points[j].y;
Edge[EdgNum+1].EdgePoint2.x=Points[k].x;
Edge[EdgNum+1].EdgePoint2.y=Points[k].y;
Edge[EdgNum+2].EdgePoint1.x=Points[k].x;
Edge[EdgNum+2].EdgePoint1.y=Points[k].y;
Edge[EdgNum+2].EdgePoint2.x=Points[i].x;
Edge[EdgNum+2].EdgePoint2.y=Points[i].y;
EdgNum=EdgNum+3;
}
else
{
Edge[EdgNum].EdgePoint1.x=Points[i].x;
Edge[EdgNum].EdgePoint1.y=Points[i].y;
Edge[EdgNum].EdgePoint2.x=Points[k].x;
Edge[EdgNum].EdgePoint2.y=Points[k].y;
EdgNum=EdgNum+1;
}
// 形成新的凸包数组。
for(long m=j;m<iConvexNum-1;m++)
{
Points[m].x=Points[m+1].x;
Points[m].y=Points[m+1].y;
iConvexNum=iConvexNum-1;
i=-1;
}
}
}
}
int _tmain(int argc, _TCHAR* argv[])
{
POINT *Points;
POINT *POINTS;
Points=new POINT[iConvexNum];
POINTS=new POINT[DATA_NUM];
TRIANGLE *Triangle;
Triangle=new TRIANGLE[MAX_TRI];
EDGE *Edge;
Edge=new EDGE[MAX_EDGE];
ConvexHullTriangle(Edge,Triangle,Points);
Delaunay_Net(Edge,Triangle,POINTS);
delete[] Points;
delete[] POINTS;
//delete[] Triangle;
// delete[] Edge;
return 0;
}
jia_xiaoxin
2008-10-30
打赏
举报
回复
如果.y前的类对象是指针对象,或者.y前的对象未定义就会出现这样的问题。
.y前的类对象是指针对象要
->y
这样使用
ytfrdfiw
2008-10-30
打赏
举报
回复
贴代码
c语言
error
c2227,
error
C2227:
left
of '->first' must point to
class
/
struct
/
union
标签:优先级今天调试程序时,遇到这么一个
错误
:
error
C2227:
left
of ‘->first‘ must point to
class
/
struct
/
union
#includeusing namespace std;#define ElemType int
struct
node{
struct
node *first;
struct
node *last;int size;};typ...
【无标题】‘.Children‘ must have
class
/
struct
/
union
tree_operations.h(97,66):
error
C2228
:
left
of '.Children' must have
class
/
struct
/
union
tree_operations.h(97,66): message : type is '_Add_reference::_Rvalue' tree_operations.h(176,41):
error
C2976:'verible::tree_operations_internal::TreeNodeChild
left
of '->GetStatus' must point to
class
/
struct
/
union
/generic type
LRESULT CALLBACK PlayWindow::PlayWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)//这是一个static成员函数 { switch (uMsg) { case WM_LBUTTONDOWN: if(m_pIPlayCtrl->GetStatus() == 3)
error
C2037:
left
of 'xxx' specifies undefined
struct
/
union
'xxx'
碰到这个问题,在一个简单的工程里面实现了重现。 定义一个结构,例如 源代码// file MInfo.h #pragma once typedef
struct
MIMainInfo { //HINSTANCE m_hInstance; //HWND m_hWnd; //HWND hwndMB; //应用是否启动 int m_bAppS...
c语言中
错误
c2228
,求大神解救!!!!!总是出现
C2228
错误
该楼层疑似违规已被系统折叠隐藏此楼查看此楼
class
ticket //存节点长度和管理数据{private:node tic[N];int len;public: ticket();~ticket();int sort(int i);void input();void show();void sell();}tick;int ticket::sort(int i){int r,n,j;for(...
C++ 语言
65,186
社区成员
250,526
社区内容
发帖
与我相关
我的任务
C++ 语言
C++ 语言相关问题讨论,技术干货分享,前沿动态等
复制链接
扫一扫
分享
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++
技术论坛(原bbs)
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
请不要发布与C++技术无关的贴子
请不要发布与技术无关的招聘、广告的帖子
请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下
试试用AI创作助手写篇文章吧
+ 用AI写文章