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