Nope. That'd be with sizeof(wchar_t), assuming there's a difference between wide and and narrow chars.Originally Posted by maxorator
Nope. That'd be with sizeof(wchar_t), assuming there's a difference between wide and and narrow chars.Originally Posted by maxorator
Last edited by zx-1; 10-09-2006 at 06:23 AM.
System: Debian Sid and FreeBSD 7.0. Both with GCC 4.3.
Useful resources:
comp.lang.c FAQ | C++ FQA Lite
I see no differences then because sizeof(char) is always 1 byte.
"The Internet treats censorship as damage and routes around it." - John Gilmore
Actually it was midnight. I just thought I'd look if there's something interesting here before I went to sleep.Originally Posted by Queatrix
"The Internet treats censorship as damage and routes around it." - John Gilmore
That's 95% correct. There is a difference, albeit a somewhat esoteric one.Originally Posted by maxorator
It was really kind of a trick question. :-)
System: Debian Sid and FreeBSD 7.0. Both with GCC 4.3.
Useful resources:
comp.lang.c FAQ | C++ FQA Lite
Hmm, you can define char to be something else?
"The Internet treats censorship as damage and routes around it." - John Gilmore
No. Answer:
8192 is the same as (int)8192.
8192 * sizeof(char) is the same as (size_t)8192.
System: Debian Sid and FreeBSD 7.0. Both with GCC 4.3.
Useful resources:
comp.lang.c FAQ | C++ FQA Lite
I think that this is another valid use of "using":I assert that porting legacy code is the only valid reason for having "using" in your code. It decreases readability; putting std:: in front of everything makes it far more clear what's going on.
At the initial point when the code was written, it is possible that the types of member1 and member2 do not yet have their own (presumably optimised) swap functions. As such, the standard swap algorithm would be used. At some later point, this might change, and thus a re-compile should have ClassName::swap pick up the optimisations automatically.Code:void ClassName::swap(ClassName& x) { using std::swap; swap(member1, x.member1); swap(member2, x.member2); }
Here is another valid use of "using":
If the "using Base::memberFunction;" was commented out, there would be a compile error, since Derived::memberFunction(int) hides the name "memberFunction" in the Base class' scope. As such, a call to Base::memberFunction() from x would be invalid.Code:#include <iostream> class Base { public: void memberFunction() { std::cout << "Base::memberFunction()" << std::endl; } virtual void memberFunction(int num) { std::cout << "Base::memberFunction(" << num << ")" << std::endl; } }; class Derived : public Base { public: using Base::memberFunction; virtual void memberFunction(int num) { std::cout << "Derived::memberFunction(" << num << ")" << std::endl; } }; int main() { Derived x; x.memberFunction(); }
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
I think Cat was referring to the using statement, not the using declaration. But far be it from me to place words in his mouth
zx-1: it actually took me two looks on your code to find the difference. Very nice example.
maxorator: no, but you need to learn good design.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
Well, I see the difference too, one of them is shorter than the other one.
"The Internet treats censorship as damage and routes around it." - John Gilmore
Look again.4. In C, it is in the <string.h> library.
I mean that you can have a generic template class, like vector<>, but also a specialized version, such as vector<bool>, which has a slightly different behaviour.6. Do you mean kind of overload the template with a template function that has parameters types specified, so when those types are used in the function, that function template is used?
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
What should you do if you detect an error while in a constructor? What about a destructor? Why is auto_ptr<> not appropriate for holding pointers that will be stored in standard containers? What is a good alternative? What is the airspeed velocity of an unladen swallow? Is that airspeed sufficient to carry a coconut?
The crows maintain that a single crow could destroy the heavens. Doubtless this is so. But it proves nothing against the heavens, for the heavens signify simply: the impossibility of crows.
Oh, sorry, accidentally compiled it as C++, stdio.h of course.Look again.
"The Internet treats censorship as damage and routes around it." - John Gilmore
The question: What header file is tolower() in?
Wrong! Better start using your grepping power.Originally Posted by maxorator
Last edited by whiteflags; 10-10-2006 at 12:38 PM. Reason: Needed more Luthor
Third time lucky.
Or man tolower or google("site:cppreference.com tolower") or countless other ways.Better start using your grepping power.
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
What's the difference? Stdio.h automatically includes ctype.h.
What do you mean by "man"?
"The Internet treats censorship as damage and routes around it." - John Gilmore