CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Mar 2009
    Posts
    40

    Red face no matching function for call

    ejercio-10.cpp: In member function âvoid ServerGroup:ecServers(int)â:
    ejercio-10.cpp:104: error: return-statement with a value, in function returning 'void'
    Pruebaejercicio10.cpp: In function âint main()â:
    Pruebaejercicio10.cpp:21: error: no matching function for call to âServerGroup:ecServers()â
    ejercio-10.cpp:87: note: candidates are: void ServerGroup:ecServers(int)

    ------------------------------------------------------------------------------------------------------
    in .h
    public:
    void decServers (int spServer)



    --------------------------------------------------------------------
    .cpp

    void ServerGroup:ecServers (int spServer)
    {
    cout<<" decServer Called "<<endl;

    if ( spServer != 0 )
    {
    spServer--;
    }
    else
    if ( servers[i] != 0 )
    {
    for (int i = 0; i < size ; i++)
    servers[i] -= 1;

    //*servers.elements--;

    }
    return spServer;
    }
    -------------------------------------------------------------------------
    main







    #include <iostream>
    #include <string>
    #include "ejercio-10.cpp"


    using namespace std;

    int main()
    {
    ServerGroup num(10);

    num. PrintArray();
    int i;
    for ( i = 0 ; i < num.length( ) ; i++)
    {
    num.PrintArray( num.decServers() ) ;
    }
    };

  2. #2
    Join Date
    Oct 2002
    Location
    Austria
    Posts
    1,284

    Re: no matching function for call

    1st error:
    in function

    void ServerGroup:ecServers (int spServer)

    Code:
    return spServer;
    The function is declared to return void. You return an int.

    2nd error:
    in main you call decServers() without any parameters
    Code:
    num.PrintArray( num.decServers() ) ;
    but ServerGroup:ecServers() wants an int as parameter.
    Kurt

  3. #3
    Join Date
    Mar 2009
    Posts
    40

    Re: no matching function for call

    thanks very much Kurt

  4. #4
    Join Date
    Mar 2009
    Posts
    40

    Unhappy error: no match for âoperator>>â in âstd::cin >> numbersâ

    ::basic_istream<_CharT, _Traits>:perator>>(std::basic_streambuf<_CharT, _Traits>*) [with _CharT = char, _Traits = std::char_traits<char>]
    Pruebaejercicio10.cpp:42: error: no match for âoperator[]â in ânumbers[i]â
    Pruebaejercicio10.cpp:44: error: expected `;' before âifâ
    Pruebaejercicio10.cpp:47: error: no match for âoperator[]â in ânumbers[i]â
    Pruebaejercicio10.cpp:50: error: no match for call to â(ServerGroup) ()â
    Pruebaejercicio10.cpp:51: error: ânumâ was not declared in this scop

    ---------------------------------------------------------------------------------------------------------------

    #if _MSC_VER > 1000
    #pragma once
    #endif


    #include <iostream>
    #include <string>
    #include "ejercio-10.cpp"


    using namespace std;
    void getElements( ServerGroup & numbers );

    int main()
    {
    ServerGroup num(10);
    // getElements( num );
    num. PrintArray();
    int i;
    for ( i = 0 ; i < num.length( ) ; i++)
    {
    num.changeSize(i * 2 );
    num.PrintArray( ) ;
    num. decServers (1);

    }
    return 0;

    };

    void getElements( ServerGroup & numbers )
    { int i = 0;
    cout << "Enter a positive integer: ";
    cin >> numbers ;
    while ( numbers[i] != -1 ) {
    i++
    if ( i == numbers.length( ) )
    numbers.changeSize( i * 2 );
    cout << "Enter a positive integer (enter -1 to stop): ";
    cin >> numbers[i];
    }
    numbers.changeSize( i );
    cout << "getElements: " << numbers( );
    num. PrintArray();

    };

  5. #5
    Join Date
    Apr 1999
    Posts
    27,449

    Re: no matching function for call

    Please use code tags when posting code. The code you posted is unreadable.

    Regards,

    Paul McKenzie

  6. #6
    Join Date
    Mar 2009
    Posts
    40

    Unhappy Re: no matching function for call

    I is tag format

  7. #7
    Join Date
    Apr 1999
    Posts
    27,449

    Re: no matching function for call

    Quote Originally Posted by olove View Post
    I is tag format
    ???

    Here is an example of code tags:
    Code:
    nt main()
    {
        ServerGroup num(10);
        // getElements( num );
        num. PrintArray();
        int i;
        for ( i = 0 ; i < num.length( ) ; i++)
        {
            num.changeSize(i * 2 );
            num.PrintArray( ) ;
            num. decServers (1);
        }
        return 0;
    };
    Note how neatly formatted the code is? Please read on the posting FAQ as to how to post code correctly.

    Regards,

    Paul McKenzie

  8. #8
    Join Date
    Oct 2011
    Posts
    1

    Post Re: no matching function for call

    You have the full code "exercise-10.cpp", "exercise-10.h" and the main. I have to rearrange to a friend and I have no time to develop it from scratch. I'm going to thank.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured