All pastes #721036 Raw Edit

Mine

public text v1 · immutable
#721036 ·published 2007-09-30 21:51 UTC
rendered paste body
struct Attribute
{
    string name, value;
};

class Element : public Node
{
    public:
        Element(const Node * parent, string & xml);
        virtual ~Element();
        
        
        const string &getTag() const { return tag; }
        const vector<const Attribute> &getAttributes() const { return attributes; }
        const vector<const Node *> &getChildren() const { return children; }
        
        virtual const string &type() const { return s_type; }
        
    private:
        string tag;
        vector<Attribute> attributes;
        vector<Node *> children;
        
        static const string s_type;
};







Mitchell-Livingstons-Computer:~/Documents/School/School/CS 340 - Object-Oriented Analysis and Design/Assignment 1 mitchell$ makeg++ -c Node.cpp
/usr/include/c++/4.0.0/ext/new_allocator.h: In instantiation of '__gnu_cxx::new_allocator<const Attribute>':
/usr/include/c++/4.0.0/bits/allocator.h:83:   instantiated from 'std::allocator<const Attribute>'
/usr/include/c++/4.0.0/bits/stl_vector.h:80:   instantiated from 'std::_Vector_base<const Attribute, std::allocator<const Attribute> >::_Vector_impl'
/usr/include/c++/4.0.0/bits/stl_vector.h:113:   instantiated from 'std::_Vector_base<const Attribute, std::allocator<const Attribute> >'
/usr/include/c++/4.0.0/bits/stl_vector.h:149:   instantiated from 'std::vector<const Attribute, std::allocator<const Attribute> >'
Element.h:20:   instantiated from here
/usr/include/c++/4.0.0/ext/new_allocator.h:78: error: 'const _Tp* __gnu_cxx::new_allocator<_Tp>::address(const _Tp&) const [with _Tp = const Attribute]' and '_Tp* __gnu_cxx::new_allocator<_Tp>::address(_Tp&) const [with _Tp = const Attribute]' cannot be overloaded
Element.h: In member function 'const std::vector<const Attribute, std::allocator<const Attribute> >& Element::getAttributes() const':
Element.h:20: error: invalid initialization of reference of type 'const std::vector<const Attribute, std::allocator<const Attribute> >&' from expression of type 'const std::vector<Attribute, std::allocator<Attribute> >'
Element.h: In member function 'const std::vector<const Node*, std::allocator<const Node*> >& Element::getChildren() const':
Element.h:21: error: invalid initialization of reference of type 'const std::vector<const Node*, std::allocator<const Node*> >&' from expression of type 'const std::vector<Node*, std::allocator<Node*> >'
make: *** [Node.o] Error 1