LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-28-2005, 01:31 AM   #1
lucky6969b
Member
 
Registered: Nov 2005
Posts: 337

Rep: Reputation: 30
Polymorphism problem


Hi,
I'm cross-compiling my app from PC Linux to ARMBE-Linux. And I'm using the
cURLlibpp library which is a http transfer library. There is a callback
inside it which I must specify in order to read data from the response data
block from a remote web server.
There are 15 different polymorphic methods inside the class called Options
which manifests itself with a no of 1-15 parameters that I can make use of.
I don't know why the compiler always goes for 3 parameters instead of 4

size_t write_data (void *ptr, size_t size, size_t nmemb, void * stream)
{
int written = fwrite (ptr, size, nmemb, stream);
return written;
}

in the main I have
try
{
cURLpp::Cleanup myCleanup;

cURLpp::Options::Url myUrl("192.168.0.19");

etc

cURLpp::Types::WriteFunctionFunc functor (write_data);
cURLpp::Options::WriteFunction *test = new
cURLpp::Options::WriteFunction(functor);
myRequest.setOpt(test);

myRequest.perform();

etc

I have re-configured the library and the app for many times but this error
is still occurring... Pls help

Webcam.cpp:204: instantiated from here
/usr/local/include/utilspp/functor/FunctorHandler.cpp:50: error: too few
arguments to function

I don't know why the compiler keeps choosing the wrong version of callback
functions


Thanks
Jack
 
Old 12-28-2005, 08:38 PM   #2
FLLinux
Member
 
Registered: Jul 2004
Location: USA
Distribution: Fedora 9, LFS 6.3, Unbuntu 8.04, Slax 6.0.7
Posts: 145

Rep: Reputation: 15
What is line 50 in the FunctorHandler.cpp file?
 
Old 12-28-2005, 08:52 PM   #3
lucky6969b
Member
 
Registered: Nov 2005
Posts: 337

Original Poster
Rep: Reputation: 30
OK
line 50
ResultType operator()(typename ParentFunctor::Param1 p1, typename
ParentFunctor::Param2 p2, typename ParentFunctor::Param3 p3)
{ return (mFun)(p1,p2,p3); }

ResultType operator()(typename ParentFunctor::Param1
p1, typename ParentFunctor::Param2 p2, typename ParentFunctor::Param3 p3,
typename ParentFunctor::Param4 p4)
{ return (mFun)(p1, p2, p3, p4); }

It's part of libcURLpp Thanks
Jack
 
Old 12-29-2005, 02:59 AM   #4
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
From the looks of your second post, mFun is your 4 argument callback, however the 3 argument operator () is called somewhere somehow (as a result of line 204 of Webcam.cpp), thereby submitting one too few arguments to your callback. Try giving stream a default value in write_data and see what happens (although that is by no means the solution.)
ta0kira

PS Your problem is with function overloading, not polymorphism.

Last edited by ta0kira; 12-29-2005 at 03:04 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Polymorphism in VBA ashirazi Programming 4 07-05-2005 04:44 PM
polymorphism in java jwn7 Programming 4 11-17-2004 04:20 AM
perl problem? apache problem? cgi problem? WorldBuilder Linux - Software 1 09-17-2003 07:45 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:50 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration