User Profile

Collapse

Profile Sidebar

Collapse
presencia
presencia
Last Activity: Jun 6 '11, 06:57 PM
Joined: Sep 27 '09
Location: Berlin, Germany
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • presencia
    replied to Problem using gdb. Unwanted optimization?
    in C
    Thanks a lot, mac11, for considering my problem and even trying different gcc versions. This is especially valuable for me since now I know a way to get my code compiled with correct debugging information.

    I just installed gcc versions 4.5 and 4.1. When I compile using gcc 4.1 the debugging information seems correct (like in your post). However, the bug stays in version 4.5. Why would the developers have changed that?

    Maybe...
    See more | Go to post

    Leave a comment:


  • presencia
    started a topic Problem using gdb. Unwanted optimization?
    in C

    Problem using gdb. Unwanted optimization?

    Hi all,

    I have a problem using gdb. I am using Eclipse-CDT as a frontend, but since this problem is obviously related to the gcc compiler or the gdb itself, I have reproduced it without Eclipse.

    Sample Program
    This small program should suffice to show my problem. I have saved this file as "main.cpp".
    Code:
    #include<vector>
    #include <iostream>
    
    struct I{
    	std::vector<unsigned>
    ...
    See more | Go to post

  • presencia
    replied to function template overloading
    in C
    Thanks for your reply.
    I am afraid, I didn't explain my problem well enough. So please let me try again:

    I want to write a global function that does something. I want it to take one parameter of any type or class it can deal with. So I write a function template instead of a function, just like this:
    Code:
    //first function template f
    template<typename T> void f(T obj){ /*do something*/ }
    Everything works well for...
    See more | Go to post

    Leave a comment:


  • presencia
    replied to function template overloading
    in C
    I am sorry I don't get it right away. What class should f be a member of?
    Why exactly do I have to make it a member function?
    And can I still call it the same way as the default version? (i.e., like: f(obj) )

    Thanks for your time!
    ~<><~~~~~~~~ presencia
    See more | Go to post

    Leave a comment:


  • presencia
    started a topic function template overloading
    in C

    function template overloading

    Hi all,

    i would appreciate help with the following problem: Please consider the code
    Code:
    #include <iostream>
    using namespace std;
    
    template<typename T> struct A{};
    template<typename T> struct B: public A<T>{};
    
    template<typename T> void f(T obj){ cout << "default\n"; }
    template<typename T> void f(A<T> obj){ cout << "special
    ...
    See more | Go to post

  • Thanks Banfa,
    I don't know why I didn't try just this before. It works, thank you. This thread is solved.
    ~<><~~~~~~~ presencia
    See more | Go to post

    Leave a comment:


  • how do I access a member class of a class template from a template child class

    Hi all,
    I got the following problem. I have two class templates, one inheriting from the other.

    Code:
    template<typename T>
    struct M{
    	class A{};
    };
    
    template<typename T>
    class B:public M<T>{
    	A a;
    };
    I know that this code is not correct. I've read about the compiler's two-phase lookup of members in template classes. So I assume that giving the...
    See more | Go to post

  • Wow, you opened my eyes.
    I really was mistakenly thinking the vector contents were allocated on the stack. Thanks for pointing that out. - And for all your time answering me so elaborately. I will use references of vectors as parameters to my functions, just as you were proposing.

    And you are right about writing short test programs rather then posting.

    You guys helped me a lot. I think I am fit for the task now (at...
    See more | Go to post

    Leave a comment:


  • I have found the boost::shared_p tr template to be quite similar to the handle classes proposed by weaknessforcats . Is that true? (I just read some of its documentation)
    Would you think it is sensible for me to write
    Code:
    boost::shared_ptr<vector<double> > v (new vector<double>(100000));
    for large vectors that I want to live on the heap? And how could I then access the elements?
    Code:
    v[5] //does that work? I don't
    ...
    See more | Go to post

    Leave a comment:


  • Thanks, very useful.
    See more | Go to post

    Leave a comment:


  • Thanks to both of you for all the discussion.
    I haver learned some stuff (f.expl., that you can access vector elements from a vector pointer with "v_ptr[i]" , thought that was only true for C arrays), got a better feeling about things (about use of stack and heap). I have now read the Handle Class Article and I liked it, was quite easy to understand.

    But all those concepts are not really new to me. I did think about...
    See more | Go to post

    Leave a comment:


  • presencia
    started a topic heap object question, and RAII advice request
    in C

    heap object question, and RAII advice request

    Hi all,
    I am still in the process of lerning how to write decent C++ code. I will appreciate any good advice or corrections. I have two questions, a technical one and one for advice for how to design my code.

    1. I have read somewhere (can't remember, must have been some tutorial page) that objects allocated on the heap can only be accessed through pointers. Thus, for example
    Code:
    vector<int> * v_ptr = new vector<
    ...
    See more | Go to post

  • Error found

    Hi everyone,
    I believe to have found the error.
    In line 31 it wrote
    Code:
    data[half+index_data]=data_evens[index_data]-diff;
    which was wrong, because I was writing "to the array" outside of its allocated bound. I probably overwrote some information needed for the delete of an array, therefore the program crashed processing the delete.
    The line should have been
    Code:
    data[half+ind
    ...
    See more | Go to post

    Leave a comment:


  • presencia
    started a topic SIGSEGV on delete[] problem, recursive function calls
    in C

    SIGSEGV on delete[] problem, recursive function calls

    Hi everyone,
    I have written a small program running fine until a Segmentation fault. Using a debugger I have localized the function the fault happens in. The Signal appears during a call to delete[] in the recursive function I have posted below. I have done some C coding before but I am fairly new to C++. I would really appreciate any help. I can't figure out where the problem is.

    The function the SIGSEGV appears in is the following....
    See more | Go to post
No activity results to display
Show More
Working...