在我爆炸之前 [英] BEFORE I EXPLODE

查看:61
本文介绍了在我爆炸之前的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

G ++提供了最无信息,最神秘,更糟糕的BULLSHIT错误

语句。


我现在正在写一个程序而且我有完成它

很快。我所遇到的问题在

下面说明:


class Blah

{

private:


int k;


public:


operator int()

{

返回k;

}


};

int main()

{

Blah const poo;


switch(poo)

{

案例1:

;

}


}

切换语句中的yokie必须是

整数类型。我的班级有一个operator int()。盛大。


请注意poo对象是const。如果我使poo

对象非const,那么上面的代码编译。但是什么

HELL的差异在于它是否会变得很好!


请一些启示,


-JKop

G++ gives the most un-informative, cryptic, BULLSHIT errors
statements.

I''m writing a program at the moment and I have to finish it
real soon. The problem I''m having is illustrated in the
following:

class Blah
{
private:

int k;

public:

operator int()
{
return k;
}

};
int main()
{
Blah const poo;

switch (poo)
{
case 1:
;
}

}
The yokie that goes in a switch statement has to be an
integral type. My class has an "operator int()". Grand.

Note that the "poo" object is const. If I make the poo
object non-const, then the above code compiles. BUT WHAT
THE HELL DIFFERENCE DOES IT MAKE IF IT''S CONST!

Some enlightenment please,

-JKop

推荐答案

JKop写道:
G ++提供了最无信息,最神秘的BULLSHIT错误声明。

我正在写一个程序,我必须尽快完成它。我正在讨论的问题如下:

类Blah
{
私人:

int k;

公众:

operator int()
{
返回k;
}

};

int main()
{
Blah const poo;

switch(poo)
{
案例1:;
}


切换语句中的yokie必须是
积分类型。我的班级有一个operator int()。盛大。

请注意poo。对象是const。如果我使poo
对象非const,那么上面的代码编译。但是,如果它是最好的那么会产生什么样的差异呢

请一些启示,
G++ gives the most un-informative, cryptic, BULLSHIT errors
statements.

I''m writing a program at the moment and I have to finish it
real soon. The problem I''m having is illustrated in the
following:

class Blah
{
private:

int k;

public:

operator int()
{
return k;
}

};
int main()
{
Blah const poo;

switch (poo)
{
case 1:
;
}

}
The yokie that goes in a switch statement has to be an
integral type. My class has an "operator int()". Grand.

Note that the "poo" object is const. If I make the poo
object non-const, then the above code compiles. BUT WHAT
THE HELL DIFFERENCE DOES IT MAKE IF IT''S CONST!

Some enlightenment please,



operator const int()


-

Ioannis Vranos

http://www23.brinkster.com/noicys


Ioannis Vranos发布:
Ioannis Vranos posted:
JKop写道:
G ++提供了最无信息,最神秘的BULLSHIT
错误陈述。

我正在写一个程序那一刻,我必须很快完成
。我所遇到的问题在以下
中有说明:
类Blah
{
私人:

int k;
<公开:

operator int()
{
返回k;
}

};

int main()
{
Blah const poo;

switch(poo)
{
案例1:
;
}


切换语句中的yokie必须是
整数类型。我的班级有一个operator int()。盛大。

请注意poo。对象是const。如果我使poo
对象非const,那么上面的代码编译。但是,如果它是最好的那么会产生什么样的差异呢

请一些启发,
G++ gives the most un-informative, cryptic, BULLSHIT errors statements.

I''m writing a program at the moment and I have to finish it real soon. The problem I''m having is illustrated in the following:
class Blah
{
private:

int k;

public:

operator int()
{
return k;
}

};
int main()
{
Blah const poo;

switch (poo)
{
case 1:
;
}

}
The yokie that goes in a switch statement has to be an
integral type. My class has an "operator int()". Grand.

Note that the "poo" object is const. If I make the poo
object non-const, then the above code compiles. BUT WHAT
THE HELL DIFFERENCE DOES IT MAKE IF IT''S CONST!

Some enlightenment please,



operator const int()


operator const int()



这是我的第一个想法。


流血的东西仍然不起作用!


单词编译器错误我想到了......


无论如何,


运算符int()返回* value *,所以它会没有

如果对象是const还是不同的话。


我能看到能够定义两者的唯一原因:


operator int()




运算符const int()


是有单独的例程在const上工作不同
对象对普通对象。


我可以把程序写成五次如果我

没有必要处理这个废话。


现在,我正在通过以下方式解决这个问题:


Blah temp(poo);


开关(临时)

直到我弄清楚到底是怎么回事! />
-JKop


-JKop


That was my first thought.

The bleeding thing still doesn''t work!

The words "compiler bug" are coming to mind...

Anyway,

the operator int() returns by *value*, so it would make no
difference whatsoever if the object was const or not.

The only reason I can see of being able to define both:

operator int()

and

operator const int()

is to have separate routines that work differently on const
objects Vs normal objects.

I could have the program written five times already if I
didn''t have to deal with this bullshit.

Right now, I''m getting around it via:

Blah temp(poo);

switch (temp)
That''s until I figure out what the hell''s going on!
-JKop

-JKop


JKop写道:
G ++给出最无信息,最神秘,更糟糕的BULLSHIT声明s。

我正在写一个程序,我必须尽快完成它。我正在讨论的问题如下:

类Blah
{
私人:

int k; <公开:

运营商int()



//意味着它没有修改k

operator int()const

//还需要默认构造函数


{
返回k;
}

};

int main()
{
Blah const poo;

switch(poo)
{
案例1:
;
}

}

切换语句中的yokie必须是<积分型。我的班级有一个operator int()。盛大。

请注意poo。对象是const。如果我使poo
对象非const,那么上面的代码编译。但是,如果它是最好的那么会产生什么样的差异呢

请一些启示,

-JKop
G++ gives the most un-informative, cryptic, BULLSHIT errors
statements.

I''m writing a program at the moment and I have to finish it
real soon. The problem I''m having is illustrated in the
following:

class Blah
{
private:

int k;

public:

operator int()

// Means it doesn''t modify k
operator int() const
// Also a default constructor is needed

{
return k;
}

};
int main()
{
Blah const poo;

switch (poo)
{
case 1:
;
}

}
The yokie that goes in a switch statement has to be an
integral type. My class has an "operator int()". Grand.

Note that the "poo" object is const. If I make the poo
object non-const, then the above code compiles. BUT WHAT
THE HELL DIFFERENCE DOES IT MAKE IF IT''S CONST!

Some enlightenment please,

-JKop




-

Ioannis Vranos

http://www23.brinkster.com/noicys


这篇关于在我爆炸之前的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆