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 876581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T11:27:22+00:00 2026-05-15T11:27:22+00:00

My question is rather simple, but I am stuck. How can I choose the

  • 0

My question is rather simple, but I am stuck. How can I choose the desired constructor from base class?

// node.h
#ifndef NODE_H
#define NODE_H

#include <vector>

// definition of an exception-class
class WrongBoundsException
{
};

class Node
{
    public:
        ...

        Node(double, double, std::vector<double>&) throw (WrongBoundsException);
        ...
};

#endif


// InternalNode.h
#ifndef INTERNALNODE_H
#define INTERNALNODE_H

#include <vector>
#include "Node.h"


class InternalNode : public Node
{
    public:
        // the position of the leftmost child (child left)
        int left_child;
        // the position of the parent
        int parent;

        InternalNode(double, double, std::vector<double>&, int parent, int left_child) throw (WrongBoundsException);

    private:
        int abcd;

};

#endif


// InternalNode.cpp

#include "InternalNode.h"

#define UNDEFINED_CHILD -1
#define ROOT -1


// Here is the problem
InternalNode::InternalNode(double a, double b, std::vector<double> &v, int par, int lc) 
throw (WrongBoundsException)
: Node(a, b, v), parent(par), left_child(lc)
{
    std::cout << par << std::endl;
}

I get:

$ g++ InternalNode.cpp

InternalNode.cpp:16: error: declaration of ‘InternalNode::InternalNode(double, double, std::vector >&, int, int) throw (WrongBoundsException)’ throws different exceptions
InternalNode.h:17: error: from previous declaration ‘InternalNode::InternalNode(double, double, std::vector >&, int, int)’

UPDATE 0: Fixed missing :

UPDATE 1: Fixed throw exception

  • 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-05-15T11:27:22+00:00Added an answer on May 15, 2026 at 11:27 am

    This simplified code compiles correctly, but doesn’t link becuase of missing constructor definition for base class:

    #include <vector>
    
    // definition of an exception-class
    class WrongBoundsException {
    };
    
    class Node {
        public:
            Node(double, double, std::vector<double>&) 
                    throw (WrongBoundsException);
    };
    
    class InternalNode : public Node {
        public:
            // the position of the leftmost child (child left)
            int left_child;
            // the position of the parent
            int parent;
    
            InternalNode(double, double, std::vector<double>&, 
                            int parent, int left_child) 
                            throw (WrongBoundsException);
        private:
            int abcd;
    
    };
    
    // Note added exception specification
    InternalNode::InternalNode(double a, double b, 
                                std::vector<double> &v, 
                        int par, int lc) throw (WrongBoundsException)
            : Node(a, b, v), parent(par), left_child(lc)
    {
    }
    

    BTW, why do you feel the need to use exception specifications? They are generally seem as a bit of a waste of time in C++.

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

Sidebar

Related Questions

my question is rather simple, if you have an pure virtual class (interface) but
I know is a rather simple question but I just can't find an appropriate
I think its a rather simple question but I couldn't really find an answer
I have a rather simple question that I could normally debug myself, but I
Rather a simple question. But the implications are vast. Over the last few weeks
Have a rather simple question. Does anyone knows if i can use jparallax both
The question is rather simple. How can I start a main method in another
A rather simple question (I think), but I don't seem to see an answer
I belive my question is rather simple but somehow I'm not reaching any success.
My question is rather simple. Let's suppose I'm executing the algorithm A star (search

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.