| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2006 人关注过本帖
标题:这个交换为什么错了啊?
取消只看楼主 加入收藏
啦啦boy
Rank: 1
等 级:新手上路
帖 子:18
专家分:0
注 册:2018-8-13
结帖率:25%
收藏
已结贴  问题点数:20 回复次数:1 
这个交换为什么错了啊?
void inversion_arr(struct Arr *pArr)
{
    int t;
    struct Arr *i;
    struct Arr *j;
    i = pArr;
    j = pArr+pArr->cnt;
    while(i<j)
    {
        t = *i;
        *i = *j;
        *j = t;
        i++;
        j--;
    }

报错:7.cpp
D:\c code\7.cpp(139) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'struct Arr' (or there is no acceptable conversion)
D:\c code\7.cpp(141) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'int' (or there is no acceptable conversion)
执行 cl.exe 时出错.

7.exe - 1 error(s), 0 warning(s)
搜索更多相关主题的帖子: 交换 struct cpp binary operator 
2018-08-24 21:30
啦啦boy
Rank: 1
等 级:新手上路
帖 子:18
专家分:0
注 册:2018-8-13
收藏
得分:0 
回复 2楼 forever74
哦哦,我明白了,那请问我该怎么改啊,我改成这样好像不对
void inversion_arr(struct Arr *pArr)
{
    int t;
    struct Arr *i;
    struct Arr *j;
    i = pArr;
    j = pArr+pArr->cnt;
    while(i<j)
    {
        t = (int)(*i);
        (int)(*i) = (int)(*j);
        (int)(*j) = t;
        i++;
        j--;
    }

报错:D:\c code\7.cpp(139) : error C2440: 'type cast' : cannot convert from 'struct Arr' to 'int'
        No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
D:\c code\7.cpp(140) : error C2440: 'type cast' : cannot convert from 'struct Arr' to 'int'
        No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
D:\c code\7.cpp(140) : error C2440: 'type cast' : cannot convert from 'struct Arr' to 'int'
        No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
D:\c code\7.cpp(141) : error C2440: 'type cast' : cannot convert from 'struct Arr' to 'int'
        No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
执行 cl.exe 时出错.

7.exe - 1 error(s), 0 warning(s)
2018-08-24 21:38
快速回复:这个交换为什么错了啊?
数据加载中...
 
   



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

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