Search:
Type: Posts; User: googler
Search:
Search took 0.06 seconds.
-
December 29th, 2007, 05:45 AM
This one looks ok. :thumb:
-
December 28th, 2007, 10:39 AM
Teabix is right. Your suggested optimization in #11 is incorrect, except in limited cases. You've swapped the order of the following 2 events:
1) The construction of the temporary RVO object...
-
December 16th, 2007, 10:50 AM
Failure to allocate automatic storage is not guaranteed to throw an exception in ISO C++. It's unspecified behavior. So is failure to allocate static storage. It's only the standard ::operator new...
-
December 16th, 2007, 07:48 AM
*this is an lvalue whose type is the type of the class containing the member function in which it appears. Anything you can do with an lvalue of class type you can do with *this.
-
December 13th, 2007, 06:37 PM
Don't worry about it, str.length() will be evaluated first. && is a short-circuit operator. You're confusing operator precedence with evaluation order. operator precedence determines the...
-
December 13th, 2007, 06:33 PM
This won't work. 0.03 is an infinite repeating binary fraction and can't be represented by floats (or doubles).
This is a better suggestion, which is to display the final result with two digits...
-
December 12th, 2007, 09:49 AM
This code should print "char const [12]". If it doesn't then it's a bug. Are you using a beta version of VS2008 or release?
#include <iostream>
template<size_t size, typename T>
const char*...
-
December 12th, 2007, 08:52 AM
Try running this program and tell me what you get
#include <iostream>
using std::cout;
using std::endl;
int main()
{
char a[12];
-
December 12th, 2007, 08:26 AM
That doesn't seem right. The typeid of arr should be the same as the typeid of "const char [12]". typeid does not detect references, but it certainly should not convert an array to a pointer to an...
-
December 12th, 2007, 07:16 AM
This doesn't work because function parameters of array type are adjusted to pointer type
void func(const char arr[12]); // is adjusted to
void func(const char *arr);
template<size_t size,...
-
December 12th, 2007, 06:56 AM
George2, this works because of a feature called template argument deduction. The template function's parameter type is "const T(&)[size]" where T and size are template parameters. The template...
-
December 11th, 2007, 05:18 PM
For the key line
cout << setw(5) << (x / y, array[x][y]);it's
printf("%5d",array[x][y]);The other outputs are simpler.
-
December 11th, 2007, 05:11 PM
I think mergesort is the best sort for linked lists, and AFAIR it's O(N lg N) for singly linked lists. Writing the code for it off the top of your head during an interview is way too complicated, so...
-
December 11th, 2007, 08:57 AM
-
December 11th, 2007, 08:48 AM
Which compiler gives you these results? I'm getting "char [12]" for typeid(buf).name(), "char *" for typeid(p).name() and typeid(buf) != typeid(p).
-
December 11th, 2007, 05:48 AM
It's undefined behavior to modify a const object.
-
December 10th, 2007, 03:41 PM
hFindHandle = (PVOID) ~ (INT_PTR) hFindHandle;
-
December 10th, 2007, 03:37 PM
See this, .... _rotl16, _rotl8, _rotr16, _rotr8
-
December 7th, 2007, 04:57 PM
All variables have been defined. variables i and k have both been initialized (to zero), but variable j has only been defined but not initialized (it has an unknown value.)
No.
-
December 7th, 2007, 04:45 PM
The union method does work, but you insist on ignoring CPUWizard.
class foo
{
public:
union
{
struct { int x, y, z; };
int data[3];
-
December 7th, 2007, 01:41 PM
I wish I had more those, then maybe my place wouldn't be such a mess... :lol:
-
December 7th, 2007, 12:52 PM
A function declared as extern "C" is required to have the same name-decoration and calling-convention as C functions. A function declared as extern "C++" (the default language-linkage) is required...
-
December 7th, 2007, 10:22 AM
Yes, I am. Language-linkage like C or C++ covers both name-mangling and calling-convention. A static member function always has C++ linkage. Visual C++ and GCC/linux allow you to convert it to a...
-
December 7th, 2007, 08:10 AM
If that's what you need to do then the only portable solution is to pass a pointer to a C++ function defined in namespace scope that's declared as extern "C".
Some implementations will allow you to...
-
December 7th, 2007, 07:55 AM
You don't really need two functions, because the std::sort template can sort both arrays and vectors. Of course, the compiler may generate a different instance of the template for each.
The array,...
|
Click Here to Expand Forum to Full Width
|