Это небольшой практический проект, я уже писал его на другом языке программирования. Теперь я изучаю c ++ с TCPPPL и Visual Studio 2019 (c ++ 14). Поэтому я пробую еще раз на c ++.
Эти коды ниже являются частью проектов, я использовал shared_ptr
как элемент list
в class ebb_detial_item
, и пусть shared_ptr будет типом вектора in class rev_dates_handle
.
Но компилятор всегда сообщает об ошибках о «попытке сослаться на удаленную функцию» (я не удалил ни одной функции) и «не могу преобразовать аргумент1 ....»: список ошибок
category_tbl.h
#ifndef CATEGORIES_TBL
#define CATEGORIES_TBL
#include <memory>
#include <vector>
#include <list>
#include "ebb_string.h"
#include "ebb_detial_item.h"
#include "rev_dates_handle.h"
namespace ebb_impl
{
class ebb_detial_item;
class category
{
private:
friend class ebb_detial_item;
my_ebbstring::ebb_string name{};
std::list<std::shared_ptr<ebb_impl::ebb_detial_item>> ebbtbl{};
// ^~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
my_utility::id_pool::id_pool<unsigned> item_id_pool;
ebb_rev_dates::rev_dates_handle rd_handle;
public:
category(my_ebbstring::ebb_string name)
: name{ name }, item_id_pool{ name }, rd_handle{ my_ebbstring::ebb_string{ "default" } } { }
~category();
category& add(ebb_detial_item* item_ptr);
category& remove(ebb_detial_item* item_ptr);
void set_rev_dates(
my_ebbstring::ebb_string plan_name,
std::shared_ptr<std::vector<unsigned>> new_plan_ptr);
};
}
#endif /*CATEGORIES_TBL*/
rev_dates_handle.h
#ifndef REV_DATES_HANDLE_H
#define REV_DATES_HANDLE_H
#include <memory>
#include "ebb_string.h"
#include <unordered_map>
#include <vector>
namespace ebb_impl
{
namespace ebb_rev_dates
{
std::vector<unsigned> default_rev_dates_vec{
0, 1, 2, 4, 7,
10, 15, 16, 30, 31,
90, 91, 150, 151, 152,
210, 211, 270, 272, 360,
370, 480, 490, 720, 750,
1080, 1180, 1440
};
class rev_dates_handle
{
private:
my_ebbstring::ebb_string name;
std::unordered_map<my_ebbstring::ebb_string, std::shared_ptr<std::vector<unsigned>>> rev_tbl_ptrs{};
public:
rev_dates_handle(my_ebbstring::ebb_string handle_name);
void add_tbl(
my_ebbstring::ebb_string tbl_name,
std::shared_ptr<std::vector<unsigned>> tbl_ptr);
// ^~~~~~~~~~~^~~~~~~~~~~
// this file is a header file so I need
// write std:: before vector, or use using indicate
// but never do it in header file (namespace pollution)
void change_tbl_rec(my_ebbstring::ebb_string name, std::shared_ptr<std::vector<unsigned>> new_tbl);
static void change_gloable_default(std::shared_ptr<std::vector<unsigned>> usr_dft_tbl);
// this is the unnormal function declaration
std::shared_ptr<std::vector<unsigned>> get_by_name(my_ebbstring::ebb_string name);
void copy(my_ebbstring::ebb_string dst_name, my_ebbstring::ebb_string src_name);
};
}
}
#endif /*REV_DATES_HANDLE_H*/