This is related to your C++ compiler behaviour. But normally, in C++ both should be uninitialized, specially in release build.
Also, I think you are referering to builtin types right? Those doesn't have default contructors. This is inherited from C long ago.
User Profile
Collapse
-
From a C++ apps on Windows you can call this function:
Code:HRESULT URLDownloadToFile( LPUNKNOWN pCaller, LPCTSTR szURL, LPCTSTR szFileName, DWORD dwReserved, LPBINDSTATUSCALLBACK lpfnCB );
Very powerful indeed. I think IE (and probably FireFox too) use the same API.Leave a comment:
-
The thing is that you might have no more RAM available but Windows will get virtually new one for you using its paging file system.
The only thing you really can be short of is a valid range of adress in the adress space. Each program under windows have 2gig of adress space no matter how much RAM you got on your system.
On Windows CE 5.0 the limit is 32 meg per process, even if more RAM is available.
So...Leave a comment:
-
There isn't.
Inside a class you can use both className<T> or className. There's synomym.
Template is very powerful. What you can also do is something like:
template <class T1>
class c
{
template<T2>
c( c<T2> const & ); //you can copy c<int> into c<long> for example.
};Leave a comment:
-
By overflow I mean maybe your intermediate value is greater than the maximum value supported by a int (~2 billion).
Did you convert intermediate variable of int by double too?
innerproduct must return a double too.
Code:void Matrix::multm(Matrix B,int r, int t) { int i=0,j=0,n=r; double temp[10][10]; for(i=0;i<r;++i) for (j=0;j<t;++j)
Leave a comment:
-
Depending on the input, having int a underlying datatype can easily overflow.
May be you can try with double. Double don't overflow easily but may lose precision over time. But int is almost sure to overflow, specialy for a 10 by 10 matrix.
Code:class Matrix { public: ~Matrix(){}; Matrix(); void readm(int r, int t); void addm(Matrix,int r,int t); void multm(Matrix,int
Leave a comment:
-
The main thing to know here is about copy constructor and references. Learn that quick if you want to improve your programming skills.
Example with builtin type (int, float, ...):
Code:int i = 0; int j = i; i = 2; ASSERT(j == 0); //is true
But, if i had a reference on i, thinkgs would have been different:...Leave a comment:
-
template instanciation is when you give a to a template class a template parameter.
Like:
Code:std::vector<string> v;
Specialization is more complex but let me try to explain it simply.
Code:template<class T> class vector { }; //base template template<class T> class vector<T *> //partial specialization
Leave a comment:
-
Code:ASSERT(iTriangles*3 >=NumTotalVerts); D3DXVECTOR3* nodeVerts = new D3DXVECTOR3[iTriangles*3]; int count = 0; for(int i=0; i<NumTotalVerts; i++) { if( pBools[i/3] ) { ASSERT(count < iTriangles*3); nodeVerts[count] = pTotalVerts[i]; count++; }
Leave a comment:
-
487. Allocator::cons truct is too limiting
http://www.open-std.org/jtc1/sc22/wg...losed.html#487
My idea behind the mistake that was made is that the wanted to allocate the unitialized memory first with a call to allocate(int count) then call the constructor with construct( void *, _Ty const &val ). They go into that direction propably to satisfy some akwards requirements from C users at...Leave a comment:
-
So far, this doesn't help me much. But at least I was right to worry about that. That what I have feared from the beginning: that I have to wait for the next C++ standard revision to be implemented! This will be done probably in 2-3 years.
From now on, .NET will be far ahead, in both terms of features and advanced concept.
This is bad news for C++ .......Leave a comment:
-
Its done. As soon as I got something from the STL master, I tell you.Leave a comment:
-
Kernel tracker shows all the timing inside the processor in microsecond for memory allocation, mutex lock/unlock and so on in a very nice graphical view.
Is was more than easy for me to measure the 162 ms taken to simply manage about 100 strings, maybe less.
The processor is a small Intel XScale 400Mhz with 32 Meg RAM.
The template is an object oriented tool designed to help code reusability and extensibility....Leave a comment:
-
Padding (or packing) is a compiler option.
What compiler are you using? It can also be controlled using #pragma directive.
Most compilers have default value of 8 (field are aligned on 8 bytes boundaries)
So:
struct S
{
double d1;
char c;
double d2;
};
will have sizeof(S) == 24;
Look for:
#pragma pack
...Leave a comment:
-
Ok. I saw it. But you don't understand.
In .NET, if you have a string object. The useful content is place somewhere in memory and referenced many many times.
List<string> is a list of reference to strings.
Also List<int> is a list of value type of int.
You then have best of both world. In C# you have pointer too in a unsafe context making possible miracles of runtime performance...Leave a comment:
-
STL provides an allocator class. Its purpose is to encapsulate memory allocation. But is done by using a syntax that support only using heap allocation. But it could have been done in a way that both is possible. C++ support that. Even the .NET support that. Because heap allocation is using much more system ressources than the stack.
You can't say: there is a standard (as standard as STL could be) and if your not happy with it, do...Leave a comment:
-
Can't have stack based STL allocator
Although STL container can't support object by reference as a template argument. To make thing worse, allocator can't support stack based allocation.
So:
std::deque<std: :string const &>
is impossible to declare.
But, it is also more than impossible to find a workaroung using a custom STL allocator because of the ugly and not object oriented design that was used. Thanks to many... -
STL By object reference container to support real-time specs
What I'd like to do and what I tought possible was to have a deque of string when the string was a reference (not a pointer)
Then I simply tried:
std::deque<std: :string const &> mFifo;
But, the compiler have some trouble with this at the first try.
From what I know, template is a powerful mecanism an STL a well programmed library. I'm using VS2005 but STLPort seems with a quick...
No activity results to display
Show More
Leave a comment: