Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8216515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:09:08+00:00 2026-06-07T12:09:08+00:00

While trying to learn about poco networking libraries here , I came across the

  • 0

While trying to learn about poco networking libraries here, I came across the following snippet:

class MyRequestHandlerFactory : public HTTPRequestHandlerFactory
{
public:
  virtual HTTPRequestHandler* createRequestHandler(const HTTPServerRequest &)
  {
    return new MyRequestHandler;
  }
};

I am having trouble understanding the return type of the method (HTTPRequestHandler*) and the arguments to the method(const HTTPServerRequest &).

Why is it that the return type a HTTPRequestHandler pointer? Does new MyRequestHandler return an address to an object which can be referred to by its base type?

Also, I understand const is used to make the reference immutable so that the method does not mutate the referenced object but there’s no name provided for the reference type and its not being used in the createRequestHandler method. Can somebody tell me what might be going on here?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T12:09:12+00:00Added an answer on June 7, 2026 at 12:09 pm

    Return type

    If you look at the “Learning Poco” code web site,

    class MyRequestHandler : public HTTPRequestHandler
    {
        // ... removed code
    };
    

    MyRequestHandler is derived from HTTPRequestHandler. So, MyRequestHandler is a HTTPRequestHandler because of inheritance. So it is valid to return a pointer to a MyRequestHandler, because it is also a pointer to a HTTPRequestHandler.

    Function Argument

    The snippet is confusing because it specifies an argument as a type but no variable name. It is in fact the same as:

    class MyRequestHandlerFactory : public HTTPRequestHandlerFactory
    {
    public:
      virtual HTTPRequestHandler* createRequestHandler(const HTTPServerRequest & notUsed)
      {
        return new MyRequestHandler;
      }
    };
    

    The ‘notUsed’ variable is … not used. So you ask, why is there an argument at all? Because it is overriding a function declared in the base class HTTPRequestHandlerFactory. This function will have an argument const HTTPServerRequest &, therefore it must also appear in the overriding function in the derived class (even though it is not used). If ‘notUsed’ were to be used in the function createRequestHandler(), the const keyword ensures that it cannot be changed inside createRequestHandler().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Why avoid while loops? I am trying to learn Python by following
I've been trying to learn about Neural Networks for a while now, and I
I've been trying to learn about Neural Networks for a while now, and I
I've been trying to learn Python, and while I'm enthusiastic about using closures in
I am trying to learn about Objective-C for iPhone development, and while going through
I have been trying to learn a bit more about delegates and lambdas while
While trying to learn a little more about regular expressions, a tutorial suggested that
I am working on a little mini compiler while trying to learn some MIPS
I am trying to learn ruby and learn how to handle a while request
I am trying to learn and writting this part of code. while testing few

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.