广义链表

时间:2019-05-03 15:19:36

标签: c++ linked-list

我正在向管理机构编写cpp程序。 我已经为LinkedList创建了代理和公司提供的可用服务。我想在提供的代理节点和服务节点之间建立链接。

我有agency_node,agency_linkedlist,service_node,service_linkedlist类,并且我想在agency_node中使用service_node *。 我宣布他们为朋友,但仍然行不通。

error: ‘Service_Node’ was not declared in this scope

这是我的实现:

//agency linked list and nodes
class Agency_Node
{
    public:
        string agency_name;
        Agency_Node* next;
        int number_of_sevices;
        int number_of_subservices;

        //*link to main service

        //two vector to store service name and address of its node 
        vector<string> services_list;
        //*second vector to store adresses

        vector<Service_Node*> subservices_list;


    private:
        friend class Service_Node;
        friend class Service_LinkedList;


};

class Agency_LinkedList
{
    public:
        Agency_LinkedList();
        void add_service_to_agency(string service_name);
        void delete_service_from_agency(string service_name);
        void add_agency(string agency_name);
        void print_agencylist();


    private:
        Agency_Node* Head;
        friend class Service_Node;
        friend class Service_LinkedList;


};

//services linked list and nodes
class Service_Node
{
    public:
        string service_name;
        Service_Node* next;
        int number_of_subservices;
        vector<string> subservices;
        vector<string> agencies_offered_this;
        bool is_agency_offer_this();   
    private:
        friend class Agency_Node;
        friend class Agency_LinkedList;  

};

class Services_LinkedList
{
    public:
        Services_LinkedList();        
        void add_service_to_list(string service_name);
        void add_subservice_to_service(string service, 
                                        string subservice);//not decleared
        void print_servicelist();
        Service_Node* find_in_services(string service_name);  

    private:
        Service_Node* Head;
        friend class Agency_Node;
        friend class Agency_LinkedList;

};
,,,,,,

0 个答案:

没有答案