User Profile

Collapse

Profile Sidebar

Collapse
sidewinder
sidewinder
Last Activity: Oct 10 '07, 10:20 AM
Joined: Sep 13 '07
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • sidewinder
    replied to global variables/passing
    in C
    Firstly thank you for your help. However my program implements a scientific method and is contained within a single source file which I believe negates some of the disadvantages of global const variables that you have outlined.

    The method is an iterative process calling several functions. Many of these functions require knowledge of some values governing a physical system. As I outlined originally these values were declared in main...
    See more | Go to post

    Leave a comment:


  • sidewinder
    started a topic global variables/passing
    in C

    global variables/passing

    Currently writing a program which uses several constant values (all numbers) in main() and also in various functions. Currently I initialise and assign these values in main() and pass the required ones to each function.

    As these values do not get changed would it be better/quicker to have these numbers defined as const global variables?

    Thanks for the help!
    See more | Go to post

  • sidewinder
    replied to Using a destructor on a Vector class
    in C
    Thank you that works! can you explain why? (I am trying to understand my code as well as write it!) Also do you know why your dynamic suggestion didnt seem to work for me?...
    See more | Go to post

    Leave a comment:


  • sidewinder
    replied to Using a destructor on a Vector class
    in C
    changed to
    Code:
    template<class T>
        VEC<T>::~VEC()
    {
      if(v != NULL) delete[] (v);
    }
    Still the same error message.
    I also tried
    Code:
    int main(void)
    {
      VEC<double> *a;
      a=new VEC<double>(10);
      int n;
        for (n=0;n<10;n++)
      {
        a[n]=double(n);
        printf("a[%d]=%e\n",n,a[n]);
      }
      delete
    ...
    See more | Go to post

    Leave a comment:


  • sidewinder
    replied to Using a destructor on a Vector class
    in C
    Using this the program compiles and runs outputting the vector but then aborts with the following error.
    *** glibc detected *** double free or corruption (top): 0x0804a008 ***...
    See more | Go to post

    Leave a comment:


  • sidewinder
    started a topic Using a destructor on a Vector class
    in C

    Using a destructor on a Vector class

    I wish to use a C++ vector class, which I have taken from the book numerical recipes. However due to the nature of the calculations I wish to perform I need to be able to delete the vectors. I thought that the line ~VEC<double>(a) ; would do this however when trying to compile using g++ I get the error
    "no match for ‘operator~’ in ‘~VEC<double>(( (const VEC<double>&)(( const VEC<double>*)(& a))))"...
    See more | Go to post
No activity results to display
Show More
Working...