inheritance #23

  • Follow


Code:
#include <iostream>
#include <cstdarg>
#include <cstdio>
#include <string>
#include <sstream>
#include <exception>
#include "aibe.h"

class DoesNotExistInSet : public std::exception {
    public:
        DoesNotExistInSet(std::string helpText =3D "Niekas") :
msg(helpText) {}
        ~DoesNotExistInSet() throw() {}
        virtual const char* what() const throw() {
            return msg.c_str();
        }
    protected:
        std::string msg;
};

class AlreadyExistInSet : public DoesNotExitInSet { // 20
    public:
        AlreadyExistInSet(std::string helpText =3D "Niekas") :
DoesNotExistInSet(helpText) {} // 22
        ~AlreadyExistInSet() throw() {}
};

aibe.cpp:20: error: expected class-name before =91{=92 token
aibe.cpp: In constructor
=91AlreadyExistInSet::AlreadyExistInSet(std::string)=92:
aibe.cpp:22: error: type =91class DoesNotExistInSet=92 is not a direct
base of =91AlreadyExistInSet=92

Started to learn more about C++ and wanted to create some specific
exception and run into problems.
Any ideas how to fix and why I am getting those errors?

0
Reply David.Abdurachmanov (50) 5/12/2008 3:12:12 PM

david wrote:
> Code:
> #include <iostream>
> #include <cstdarg>
> #include <cstdio>
> #include <string>
> #include <sstream>
> #include <exception>
> #include "aibe.h"
> 
> class DoesNotExistInSet : public std::exception {
>     public:
>         DoesNotExistInSet(std::string helpText = "Niekas") :
> msg(helpText) {}
>         ~DoesNotExistInSet() throw() {}
>         virtual const char* what() const throw() {
>             return msg.c_str();
>         }
>     protected:
>         std::string msg;
> };
> 
> class AlreadyExistInSet : public DoesNotExitInSet { // 20
>     public:
>         AlreadyExistInSet(std::string helpText = "Niekas") :
> DoesNotExistInSet(helpText) {} // 22
>         ~AlreadyExistInSet() throw() {}
> };
> 
> aibe.cpp:20: error: expected class-name before �{� token
> aibe.cpp: In constructor
> �AlreadyExistInSet::AlreadyExistInSet(std::string)�:
> aibe.cpp:22: error: type �class DoesNotExistInSet� is not a direct
> base of �AlreadyExistInSet�
> 
> Started to learn more about C++ and wanted to create some specific
> exception and run into problems.
> Any ideas how to fix and why I am getting those errors?
> 

Yeah, correct the typo on line 20.
0
Reply no.spam9 (2339) 5/12/2008 3:46:05 PM


1 Replies
35 Views

(page loaded in 0.055 seconds)

Similiar Articles:













7/30/2012 3:53:23 AM


Reply: