Redian新闻
>
想业余时间做点副业
avatar
想业余时间做点副业# EE - 电子工程
z*i
1
入关后,转飞机要付行李费吗?
我父母乘坐CO的飞机,国际航线行李是免费的,但是到美国后腰转机,我想问一下,因
为入关时要取行李的,那转乘的那趟飞机,还需要付行李费吗?
avatar
y*9
2
机箱热得滚滚烫,给宝宝放音乐机器老死机。怎么办啊?房东很抠,不让多开冷气。
avatar
m*r
3
class example {
public:
example(string str){
cout <example() {
cout<example( example& rhs){
cout<};
int main (int argc, char* argv[])
{
string str = "123456789";
example e1(str);
example e2 = str;
example e3 = e1;
example e4 = example();
return 0;
}
这个例子来自C++Primer,在VS2010可以编译,gcc下e2 and e4报错:no matching
function for call to example::example(example)
如果在copy constructor里加上const,gcc可以编译。我的理解是初始化e2 and e4需要
产生临时对象,这个对象是右值,C++标准可能要求形参const以接受右值,为什么VS没
报错不明白。
但是除了e3,copy constructor在初始化e2和e4的时候没有调用,
而C++Primer说这种是copy-initialization,那为什么在VS和gcc下都没有调用copy
constructor?被优化了?
隐式调用copy constructor是不是有编译器决定?
avatar
h*g
4
诸如 [Cu(MeCN)4]BF4 在酰氯-COCl存在下稳定吗,会有什么副反应吗?谢谢了。
avatar
N*g
5
想业余时间给中小公司做点设计啥的,请问如何能够让别人知道自己的存在呢?好像往
别人公司的director,manager发自荐email也不太合适吧。那么建网站?还有什么招呢
avatar
i*n
6
联程票不用,单独买的票要付

【在 z******i 的大作中提到】
: 入关后,转飞机要付行李费吗?
: 我父母乘坐CO的飞机,国际航线行李是免费的,但是到美国后腰转机,我想问一下,因
: 为入关时要取行李的,那转乘的那趟飞机,还需要付行李费吗?

avatar
t*o
7
能热到滚烫这种地步,开冷气也不管用。太不环保了,换别的设备放音乐吧

机箱热得滚滚烫,给宝宝放音乐机器老死机。怎么办啊?房东很抠,不让多开冷气。

【在 y**********9 的大作中提到】
: 机箱热得滚滚烫,给宝宝放音乐机器老死机。怎么办啊?房东很抠,不让多开冷气。
avatar
t*t
8
copy-initialization不代表需要用copy constructor, 请勿望文生义

【在 m********r 的大作中提到】
: class example {
: public:
: example(string str){
: cout <: example() {
: cout<: example( example& rhs){
: cout<: };
: int main (int argc, char* argv[])

avatar
z*i
9
谢谢,有人最近坐过CO的航班吗?怎么样呢?

【在 i*n 的大作中提到】
: 联程票不用,单独买的票要付
avatar
d*n
10
啥机器啥cpu啊?把机箱打开清一下灰,看看风扇还转不转?
avatar
p*g
11
M$'s VS is just not very standard compliant. so try to avoid using it as
much as possible if u r still learning c++.

【在 m********r 的大作中提到】
: class example {
: public:
: example(string str){
: cout <: example() {
: cout<: example( example& rhs){
: cout<: };
: int main (int argc, char* argv[])

avatar
s*x
12
怎么买的呢

【在 z******i 的大作中提到】
: 谢谢,有人最近坐过CO的航班吗?怎么样呢?
avatar
m*e
13
机器这么热不正常,最好的办法是找懂的人看一下。
如果显卡发热量大就换一个,如果超频就降下来。
如果显卡不热,也没超频,风扇没问题,就尽早换一个吧,机器支持不了几天了。
avatar
f*y
14
e2,e4不需要产生临时对象。
我觉得VS在这个上好像更标准一些。

【在 m********r 的大作中提到】
: class example {
: public:
: example(string str){
: cout <: example() {
: cout<: example( example& rhs){
: cout<: };
: int main (int argc, char* argv[])

avatar
z*i
15
网上,在国内订的电子票啊,是连程的

【在 s******x 的大作中提到】
: 怎么买的呢
avatar
t*t
16
99% time, VS is "更不标准". for c++, if VS has different error information
with gcc, 99.99% time VS is wrong.

【在 f******y 的大作中提到】
: e2,e4不需要产生临时对象。
: 我觉得VS在这个上好像更标准一些。

avatar
k*g
17

why not 99.
9999999999999999999999999999999999999999999999999999999999999999999999999999
999999999999999999% wrong?
you can add as many 9's as you want. there's no character limit in messages
in mitbbs.

【在 t****t 的大作中提到】
: 99% time, VS is "更不标准". for c++, if VS has different error information
: with gcc, 99.99% time VS is wrong.

avatar
t*t
18
你想说啥...99或99.99就是个说法, 我显然没真的统计过.

9999999999999999999999999999999999999999999999999999999999999999999999999999
messages

【在 k**********g 的大作中提到】
:
: why not 99.
: 9999999999999999999999999999999999999999999999999999999999999999999999999999
: 999999999999999999% wrong?
: you can add as many 9's as you want. there's no character limit in messages
: in mitbbs.

avatar
t*c
19
http://stackoverflow.com/questions/1051379/is-there-a-differenc
Delving into Initializations Direct and Copy initialization
While they look identical and are supposed to do the same, these two forms
are remarkably different in certain cases. The two forms of initialization
are direct and copy initialization:
T t(x);
T t = x;
There is behavior we can attribute to each of them:
Direct initialization behaves like a function call to an overloaded function
ones), and the argument is x. Overload resolution will find the best
matching constructor, and when needed will do any implicit conversion
required.
Copy initialization constructs an implicit conversion sequence: It tries to
convert x to an object of type T. (It then may copy over that object into
the to-initialized object, so a copy constructor is needed too - but this is
not important below)
As you see, copy initialization is in some way a part of direct
initialization with regard to possible implicit conversions: While direct
initialization has all constructors available to call, and in addition can
do any implicit conversion it needs to match up argument types, copy
initialization can just set up one implicit conversion sequence.
avatar
m*r
20
如果不需要,为什么没有const的时候GCC编译出错?
C++ Primer里明确说需要用copy constructor
但编译器怎么实现的我就不肯定了

【在 t****t 的大作中提到】
: copy-initialization不代表需要用copy constructor, 请勿望文生义
avatar
a*i
21
需要定义一个copy constructor,但不会被调用。
MS的不出错是因为MS的编译器作了extension,可以用non-const reference绑定rvalue
。这个extension可能是为了编译一些old code。可以用/Za来disable,也可以用/W4来
看到warning。

【在 m********r 的大作中提到】
: 如果不需要,为什么没有const的时候GCC编译出错?
: C++ Primer里明确说需要用copy constructor
: 但编译器怎么实现的我就不肯定了

avatar
f*y
22
copy initialization在什么情况下有用呢?

function

【在 t*******c 的大作中提到】
: http://stackoverflow.com/questions/1051379/is-there-a-differenc
: Delving into Initializations Direct and Copy initialization
: While they look identical and are supposed to do the same, these two forms
: are remarkably different in certain cases. The two forms of initialization
: are direct and copy initialization:
: T t(x);
: T t = x;
: There is behavior we can attribute to each of them:
: Direct initialization behaves like a function call to an overloaded function
: ones), and the argument is x. Overload resolution will find the best

avatar
t*t
23
需要copy constructor不等于用copy constructor, 注意下面最后一句话.
Otherwise (i.e., for the remaining copy-initialization cases), user-defined
conversion sequences that can convert from the source type to the
destination type or (when a conversion function is used) to a derived class
thereof are enumerated as described in 13.3.1.4, and the best one is chosen
through overload resolution (13.3). If the conversion cannot be done or is
ambiguous, the initialization is ill-formed. The function selected is called
with the initializer expression as its argument; if the function is a
constructor, the call initializes a temporary of the cv-unqualified version
of the destination type. The temporary is a prvalue. The result of the call
(which is the temporary for the constructor case) is then used to direct-
initialize, according to the rules above, the object that is the destination
of the copy-initialization. In certain cases, an implementation is
permitted to eliminate the copying inherent in this direct-initialization by
constructing the intermediate result directly into the object being
initialized; see 12.2, 12.8.

【在 m********r 的大作中提到】
: 如果不需要,为什么没有const的时候GCC编译出错?
: C++ Primer里明确说需要用copy constructor
: 但编译器怎么实现的我就不肯定了

avatar
d*i
24
你这个e4这样直接调contructor对吗?还是我搞糊涂了?
example e4 = example();
一般按常规应改写成
example e4;

example *e4 = new example();

example *e4 = new example;

【在 m********r 的大作中提到】
: class example {
: public:
: example(string str){
: cout <: example() {
: cout<: example( example& rhs){
: cout<: };
: int main (int argc, char* argv[])

avatar
t*t
25
你搞涂了

【在 d****i 的大作中提到】
: 你这个e4这样直接调contructor对吗?还是我搞糊涂了?
: example e4 = example();
: 一般按常规应改写成
: example e4;
: 或
: example *e4 = new example();
: 或
: example *e4 = new example;

avatar
d*i
26
这个是C++11的新标准吗?我见过的都不是这么写的,这么写看着有点怪。

【在 t****t 的大作中提到】
: 你搞涂了
avatar
f*y
27
不是新标准。

【在 d****i 的大作中提到】
: 这个是C++11的新标准吗?我见过的都不是这么写的,这么写看着有点怪。
avatar
d*i
28
是我搞糊涂了,不过非常不喜欢这种创建对象的写法,如果是stack variable,写成
MyClass a;
MyClass a(10, 1);
不就成了吗?写成MyClass a = MyClass()有点脱裤子放屁,多此一举。而且C++的code
style应该尽量保持和C一样,第二种写法非常不好,C里面stack变量不就是
typedef struct {
...
} MyStruct;
MyStruct a;

【在 t****t 的大作中提到】
: 你搞涂了
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。