-
April 5th, 2009, 07:07 AM
#1
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() ) ;
}
};
-
April 5th, 2009, 07:19 AM
#2
Re: no matching function for call
1st error:
in function
void ServerGroup:ecServers (int 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
-
April 5th, 2009, 02:47 PM
#3
Re: no matching function for call
-
April 5th, 2009, 02:52 PM
#4
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();
};
-
April 5th, 2009, 04:29 PM
#5
Re: no matching function for call
Please use code tags when posting code. The code you posted is unreadable.
Regards,
Paul McKenzie
-
April 5th, 2009, 08:34 PM
#6
Re: no matching function for call
-
April 5th, 2009, 08:59 PM
#7
Re: no matching function for call
Originally Posted by olove
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
-
October 19th, 2011, 11:14 PM
#8
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|