User Profile

Collapse

Profile Sidebar

Collapse
OuaisBla
OuaisBla
Last Activity: Mar 21 '08, 10:12 PM
Joined: Jun 20 '07
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • OuaisBla
    replied to Please clear it off (global n local)
    in C
    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.
    See more | Go to post

    Leave a comment:


  • OuaisBla
    replied to Download software C, C++
    in C
    From a C++ apps on Windows you can call this function:


    Code:
    HRESULT URLDownloadToFile(          LPUNKNOWN pCaller,
        LPCTSTR szURL,
        LPCTSTR szFileName,
        DWORD dwReserved,
        LPBINDSTATUSCALLBACK lpfnCB
    );
    http://msdn2.microsoft .com/en-us/library/ms775123.aspx

    Very powerful indeed. I think IE (and probably FireFox too) use the same API.
    See more | Go to post

    Leave a comment:


  • OuaisBla
    replied to exception: std::bad_alloc
    in C
    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...
    See more | Go to post

    Leave a comment:


  • OuaisBla
    replied to copy constructors for template classes
    in C
    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.

    };
    See more | Go to post

    Leave a comment:


  • OuaisBla
    replied to Classes Matrix question
    in C
    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)
    ...
    See more | Go to post

    Leave a comment:


  • OuaisBla
    replied to Classes Matrix question
    in C
    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
    ...
    See more | Go to post

    Leave a comment:


  • OuaisBla
    replied to function Declaration&Definition
    in C
    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
    j is a copy of i at a given time. So changing i doesn't affect j;

    But, if i had a reference on i, thinkgs would have been different:...
    See more | Go to post

    Leave a comment:


  • template instanciation is when you give a to a template class a template parameter.

    Like:

    Code:
    std::vector<string> v;
    v is an instanciation of a template.

    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
    ...
    See more | Go to post

    Leave a comment:


  • OuaisBla
    replied to exception: std::bad_alloc
    in C
    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++;
            }
    ...
    See more | Go to post

    Leave a comment:


  • OuaisBla
    replied to Can't have stack based STL allocator
    in C
    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...
    See more | Go to post

    Leave a comment:


  • OuaisBla
    replied to Can't have stack based STL allocator
    in C
    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++ .......
    See more | Go to post

    Leave a comment:


  • OuaisBla
    replied to Can't have stack based STL allocator
    in C
    Its done. As soon as I got something from the STL master, I tell you.
    See more | Go to post

    Leave a comment:


  • OuaisBla
    replied to Can't have stack based STL allocator
    in C
    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....
    See more | Go to post

    Leave a comment:


  • OuaisBla
    replied to Structure Padding
    in C
    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
    ...
    See more | Go to post

    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...
    See more | Go to post

    Leave a comment:


  • OuaisBla
    replied to Can't have stack based STL allocator
    in C
    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...
    See more | Go to post

    Leave a comment:


  • OuaisBla
    started a topic Can't have stack based STL allocator
    in C

    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...
    See more | Go to post

  • 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...
    See more | Go to post
No activity results to display
Show More
Working...