no matching function for call
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Thread: no matching function for call

  1. #1
    Join Date
    Mar 2009
    Posts
    40

    Red face no matching function for call

    ejercio-10.cpp: In member function ‚void ServerGroup::decServers(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::decServers()‚
    ejercio-10.cpp:87: note: candidates are: void ServerGroup::decServers(int)

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



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

    void ServerGroup::decServers (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::decServers (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::decServers() 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,418

    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,418

    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
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center