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

  • Home
  • SEARCH
  • 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 143069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T08:02:13+00:00 2026-05-11T08:02:13+00:00

I have a C++ class and I am trying to run it in Ubuntu:

  • 0

I have a C++ class and I am trying to run it in Ubuntu:

#ifndef WRONGPARAMETEREXCEPTION_H_ #define WRONGPARAMETEREXCEPTION_H_  #include <iostream> #include <exception> #include <string>  using namespace std;  #pragma once  class WrongParameterException: public exception {     public:         WrongParameterException(char* message): exception(message) {};         virtual ~WrongParameterException() throw() {}; };   #endif 

when I try to compile it, the compiler gives me this error:

WrongParameterException.h: In constructor ‘WrongParameterException::WrongParameterException(char*)’: WrongParameterException.h:14: error: no matching function for call to ‘std::exception::exception(char*&)’ /usr/include/c++/4.3/exception:59: note: candidates are: std::exception::exception() /usr/include/c++/4.3/exception:57: note: std::exception::exception(const std::exception&) 

Can anyone tell me what am I doing wrong? I tried changing the message variable to string or const string or const string& but it didn’t help.

Here is how I use the new exception that I created from main:

try {      if ((strToInt1 == -1) || (parameters[1] == NULL) || (strToInt3 == -1) || (parameters[3] != NULL))      {           throw WrongParameterException('Error in the config or commands file');      } } catch(WrongParameterException e) {      log.addMsg(e.what()); } 
  • 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. 2026-05-11T08:02:13+00:00Added an answer on May 11, 2026 at 8:02 am

    First, #pragma once is the wrong way to go about it, learn about header include guards. Related question on SO explains why using #pragma once is the wrong way to go about it. Wikipedia explains how to use include guards which serve the same purpose without any of the downsides.

    Second, you are calling the constructor of std::exception with a parameter it does not know, in this case a pointer to a character array.

    #include <stdexcept> #include <string>  class WrongParameterException : public std::runtime_error { public:     WrongParameterException(const std::string& message)          : std::runtime_error(message) { }; }; 

    Would probably be what you want. For more information on exceptions, check out C++ FAQ Lite article on Exceptions and the exceptions article at cplusplus.com.

    Good luck!

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

Sidebar

Related Questions

I have a test class that I'm trying to run from a main method
I am trying to query SQL Server database from C# I have class Class_A
I'm trying to have a Class.prototype based classes in my project, where I don't
I'm trying to validate an ID. I have this class called ManejadorTickets in which
I am trying to create downloading progress. I have my class which extends AsyncTask:
I'm trying to figure out if this is possible. I have a class, BaseGameEntity,
Ok here is what I am currently trying to do. I have a class
I have a simple Class Hierarchy that I am trying to get to work
I have an the following class I'm trying to create a list of with
I have the following class written by someone else that I'm trying to understand

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.