|
IMHO VC++ answer makes sense.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
It's a correct answer, but maybe not what was intended.
It seems to be evaluating it as ((a+=3), 5, a) and returning the new value of 'a' (the AS/400 compiler returns the old value of 'a' I think).
I'll have to find a precedence table, as I'd have expected it to be (a += (3, 5, a)), which would give a different result (4)...
edit : looks like the assignment has higher precedence, according to MSDN. You learn something new every day
There are three kinds of people in the world - those who can count and those who can't...
|
|
|
|
|
int <font color=red>a</font> = 1;
a += ( <font color=red>a</font>+= 3, <font color=gray>5, a</font> );
a += ( <font color=red>a</font>+= 3 );
a += ( a = <font color=red>a</font>+3)
a += a;
shubhi wrote: In AS/400’s C showing output: 5
Then that compiler sucks.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
But according to sequential Evaluation:
say If,
a=(b+=2,5,2)
then it will evaluate b+=2 but a will get the value 2, as I m using the braces here.
So i think in my question it is evaluating the a+=3 but finally it is resulting the value of last argument.
a += ( a+= 3, 5, a ); //a=1
a += ( a );//a=4
kindly correct me know if I m wrong.
"We can't solve problems by using the same kind of thinking we used when we created them"
|
|
|
|
|
shubhi wrote: then it will evaluate b+=2 but a will get the value 2, as I m using the braces here.
You're right there.
shubhi wrote: a += ( a+= 3, 5, a ); //a=1
Yes, the value of a (the last within the braces) is 1 , so adding 3 to it makes it 4 . And then there is an a+=a . Therefore 8.
It is a crappy thing, but it's life -^ Carlo Pallini
modified on Monday, June 8, 2009 7:04 AM
|
|
|
|
|
Rajesh R Subramanian wrote: a cannot get the value 2, because the expression b+=2 will be executed before it is assigned to a, for the very reason that it is inside braces. Therefore, the value of a would be b+2.
I think you're wrong, here (and the OP question was indeed more subtle than I origianlly understood).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Yes, that was subtle indeed. Modified my answer.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Just to add
For eg we have
e1 , e2
Here ',' act as operator which will ``evaluate the subexpression e1, then evaluate e2; the value of the expression is the value of e2.
So for a+=(a+=3,5,a) it will have as:-
a+=(4,5,4)// since a=a+3
So in all a=8.
But not sure of AS/400 C Compiler. Might be it is evaluating as:-
a+=(a+=3.5,a)
a=a+(a=a+3,5,a)
a=1+(4,5,4)
a=5 // But i am not sure with this explanation.
|
|
|
|
|
Anoop Dashora wrote: But not sure of AS/400 C Compiler. Might be it is evaluating as:-
a+=(a+=3.5,a)
a=a+(a=a+3,5,a)
a=1+(4,5,4)
a=5 // But i am not sure with this explanation.
You could generate the assembly and have a look at it, couldn't you?
[added]
Probably you can't, since you're not the OP...
[/added]
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hello, I modified a portion of my previous answer. To be specific,
shubhi wrote:
a=(b+=2,5,2)
then it will evaluate b+=2 but a will get the value 2, as I m using the braces here.
That is correct.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Who cares what the answer is or should be or whatever - the lesson you should be learning from this question is just don't do this sort of thing.
[edit]To expand on that - whenever some part of a language specification is defined as "implementation specific" or (as I think the C++ Standard says for cases like yours) "undefined", especially when it's language semantics like this, be afraid, be very afraid, and leave it well alone, as far as you are able.[/edit]
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
modified on Monday, June 8, 2009 8:30 AM
|
|
|
|
|
Hi again. trying to design a gui which would access certain certificate information and display it in the interface under appropriate columns. when I designed the code to display the information in the console I used pIStore->Open(CAPICOM_CURRENT_USER_STORE,bstrName,CAPICOM_STORE_OPEN_READ_ONLY) where pIStore is a IStorePtr and bstrName is defiend as: _bstr_t bstrName = _T("My");
how can i access the certificate store now if i wish to get information from it and display it in rows using ListBox? (I am guiding myself on the sample code for opening and displaying a database, provided by Visual Studio 8.0 MFC examples (project is called DBVList))
|
|
|
|
|
i am sure that there are lots of examples which displays the values in listbox from a database in Codeproject. Please do a google search. you will go bonkers on the number of search results that you will get.
|
|
|
|
|
well the c++ example given by Visual Studio samples opened a Microsoft Access database, and it opened it by calling its file name and passing it as a string:
return _T("filename.mdb");
i tried doing that with the Store, and I think I managed to do something lol. but I will search for the keywords of displaying values in listbox from database. thanks
|
|
|
|
|
i think you need to do some settings in the control panel to use your store database. btw are you using MFC?
|
|
|
|
|
yes I'm using mfc, atleast learning about it as I go along with this
|
|
|
|
|
Hello,
can anyone help me how can i get a Bitmap* of the drawing done on my view currently. I have CDC* of my current view i want to get Bitmap* of Whole drawing done on the CDC* of my current view
thnx !!
|
|
|
|
|
I suppose this article [^] maybe useful.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
You are welcome.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I have to open a given document, without calling the application which opens it.
Semiliar to double clicking a document which opens it with the attached application (but without realy double click, just call some windows API for open document...)
Thanks
Yossi Malka
|
|
|
|
|
|
Perfect solution, Thanks.
Yossi Malka
|
|
|
|
|
Hi,
I am confused regarding choosing one declaration from a set of two. I could not decided which one should be preferred over other and why it should be preferred. Please see the declarations below and let me know out of (I) and (II) which declaration is more preferred and why.
(I)
#if defined (UNICODE) && defined (_UNICODE)
typedef std::wstring _tstring;
#else
typedef std::string _tstring;
#endif
(II)
#if defined (UNICODE) && defined (_UNICODE)
#define _tstring std::wstring
#else
typedef _tstring std::string;
#endif
Thanks and Regards
|
|
|
|
|
I would choose typedef . You may google a bit [^] to find comparisons.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|