Re: Simple argument question

Discussion in 'C++' started by Krice, Dec 18, 2011.

  1. Krice

    Krice Guest

    On 17 joulu, 02:46, Bint <> wrote:
    > And then call the function with points as the argument?  It doesn't compile


    Let's rewrite this to C++:

    1. Create a point class or struct with x, y, z variables
    2. Use std::vector to store them if you don't know the size of the
    array
    3. Pass vector's reference to a function processing the array
     
    Krice, Dec 18, 2011
    #1
    1. Advertising

  2. Krice <> wrote:
    > On 17 joulu, 02:46, Bint <> wrote:
    > > And then call the function with points as the argument?  It doesn't compile


    > Let's rewrite this to C++:


    > 1. Create a point class or struct with x, y, z variables
    > 2. Use std::vector to store them if you don't know the size of the
    > array
    > 3. Pass vector's reference to a function processing the array


    Fine as long as the function receiving the array of points isn't
    some external function from a library written in C that can't be
    simply made to work with C++ classes and vectors...

    Regards, Jens
    --
    \ Jens Thoms Toerring ___
    \__________________________ http://toerring.de
     
    Jens Thoms Toerring, Dec 18, 2011
    #2
    1. Advertising

  3. Krice

    Jorgen Grahn Guest

    On Sun, 2011-12-18, Jens Thoms Toerring wrote:
    > Krice <> wrote:
    >> On 17 joulu, 02:46, Bint <> wrote:
    >> > And then call the function with points as the argument?  It doesn't compile

    >
    >> Let's rewrite this to C++:

    >
    >> 1. Create a point class or struct with x, y, z variables
    >> 2. Use std::vector to store them if you don't know the size of the
    >> array
    >> 3. Pass vector's reference to a function processing the array

    >
    > Fine as long as the function receiving the array of points isn't
    > some external function from a library written in C that can't be
    > simply made to work with C++ classes and vectors...


    Surely we cannot assume that is the case? He /did/ post to
    comp.lang.c++ and said nothing about such limitations as far as I can
    tell.

    /Jorgen

    --
    // Jorgen Grahn <grahn@ Oo o. . .
    \X/ snipabacken.se> O o .
     
    Jorgen Grahn, Dec 19, 2011
    #3
  4. Jorgen Grahn <> wrote:

    > Surely we cannot assume that is the case? He /did/ post to
    > comp.lang.c++ and said nothing about such limitations as far as I can
    > tell.
    >
    > /Jorgen


    He /did/ say that he wants to call a library function. Whether that library
    is in C or C++ is not important, since the signature is valid C++.

    Normally if someone speaks of library function, he means a function that he
    cannot modify himself. And even if he could, he asked how to /call/ that
    function not how to turn the function into beautiful C++.

    Of course it is not bad to give advice how to write beautiful C++ code, but
    you cannot say that the question was not detailed enough.

    Tobi
     
    Tobias Müller, Dec 19, 2011
    #4
  5. Krice

    Jorgen Grahn Guest

    On Mon, 2011-12-19, Tobias Müller wrote:
    > Jorgen Grahn <> wrote:
    >
    >> Surely we cannot assume that is the case? He /did/ post to
    >> comp.lang.c++ and said nothing about such limitations as far as I can
    >> tell.
    >>
    >> /Jorgen

    >
    > He /did/ say that he wants to call a library function. Whether that library
    > is in C or C++ is not important, since the signature is valid C++.


    Oops, my mistake. He did write:
    >>> I need to call a library function which expects an argument like this
    >>> Function(double pointlist[][3]);


    It's an unfortunate choice of interface even for a C function IMHO,
    but it's probably not something he has control over.

    /Jorgen

    --
    // Jorgen Grahn <grahn@ Oo o. . .
    \X/ snipabacken.se> O o .
     
    Jorgen Grahn, Dec 20, 2011
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bhushit Joshipura

    defaulting argument to previous argument

    Bhushit Joshipura, Dec 29, 2003, in forum: C++
    Replies:
    5
    Views:
    421
  2. Ben Kial
    Replies:
    1
    Views:
    704
    Eric Enright
    Nov 15, 2004
  3. S?ren Gammelmark
    Replies:
    1
    Views:
    1,968
    Eric Sosman
    Jan 7, 2005
  4. nw
    Replies:
    0
    Views:
    334
  5. Reckoner
    Replies:
    11
    Views:
    728
    Steven D'Aprano
    Jan 19, 2009
Loading...

Share This Page