我自己简单写了一个cout,但是在out<<std::endl的时候出错了,要怎么改啊

我自己简单写了一个cout,但是在out<<std::endl的时候出错了,要怎么才能使我的out像cout一样能用endl

c++

3个回答

template<class _Elem,
    class _Traits> inline
    basic_ostream<_Elem, _Traits>&
        __CLRCALL_OR_CDECL endl(basic_ostream<_Elem, _Traits>& _Ostr)
    {   // insert newline and flush stream
    _Ostr.put(_Ostr.widen('\n'));
    _Ostr.flush();
    return (_Ostr);
    }

这是std里对endl的实现,可以看到它里面有两步 先输出换行符'\n' 然后flush对缓存区进行刷新。其实你可以直接out<'\n';就可以换行
或者你自己的out继承一下ostream,但是这样做可能会有个问题 就是<< 操作符也需要支持重载才行。还有一种方式是你自己写一个endl在你的
out里,用名空间和cout的endl进行区分

/** Thread safe cout class
  * Exemple of use:
  *    PrintThread{} << "Hello world!" << std::endl;
  */
class PrintThread: public std::ostringstream
{
public:
    PrintThread() = default;

    ~PrintThread()
    {
        std::lock_guard<std::mutex> guard(_mutexPrint);
        std::cout << this->str();
    }

private:
    static std::mutex _mutexPrint;
};

std::mutex PrintThread::_mutexPrint{};
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
c++中std::cout和printf之间的区别

就是这样的,在一循环体中 for(int i=0; i<len; i++) { cout<<"ms["<<i<<"]="<<ms[i]<<endl; printf("ms[%d]=%d\n", i, ms[i]); } 用cout可以遍历数组,而用printf不能?

为什么我看了这个关于高校人员信息管理系统设计的代码运行时总是会说找不到“common.h”这个文件,这个那里有错误呢?

#ifndef COMMON_H_INCLUDED #define COMMON_H_INCLUDED #include<string> #include<iostream> #include<iomanip> class COMMON { protected: std::string name; bool sex; int age; std::string id; static int person_sum; static int man_sum; static int woman_sum; public: COMMON(std::string a, bool b, int c, std::string d); virtual ~COMMON(); static int get_person_sum(); static int get_man_sum(); static int get_woman_sum(); virtual void show(){} virtual void show_row(){} virtual bool change(){} std::string get_name(){return name;} bool get_sex(){return sex;} int get_age(){return age;} std::string get_id(){return id;} }; int COMMON::person_sum = 0; int COMMON::man_sum = 0; int COMMON::woman_sum = 0; int COMMON::get_person_sum() { return person_sum; } int COMMON::get_man_sum() { return man_sum; } int COMMON::get_woman_sum() { return woman_sum; } COMMON::COMMON(std::string a, bool b, int c, std::string d): name(a), sex(b), age(c), id(d) { person_sum++; if(b) man_sum++; else woman_sum++; } COMMON::~COMMON() { person_sum--; if(sex) man_sum--; else woman_sum--; } #endif // COMMON_H_INCLUDED tester.h 实验员: #ifndef TESTER_H_INCLUDED #define TESTER_H_INCLUDED #include"common.h" class TESTER: public COMMON { private: std::string laboratory; std::string title; static int tester_sum; public: TESTER(std::string a = "haha", bool b = 1, int c = 19, std::string d = "1", std::string e = "tt", std::string f = "学生"); ~TESTER(); static int get_tester_sum(); virtual void show(); virtual void show_row(); virtual bool change(); std::string get_laboratory(){return laboratory;} std::string get_title(){return title;} }; int TESTER::tester_sum = 0; int TESTER::get_tester_sum() { return tester_sum; } TESTER::TESTER(std::string a, bool b, int c, std::string d, std::string e, std::string f): COMMON(a,b,c,d), laboratory(e), title(f) { tester_sum++; } TESTER::~TESTER() { tester_sum--; } void TESTER::show() { std::cout << "实验员:\n"; std::cout << "姓名:\t\t" << name << std::endl; std::cout << "姓别:\t\t"; if(sex) std::cout << "男\n"; else std::cout << "女\n"; std::cout << "年龄:\t\t" << age << std::endl; std::cout << "ID:\t\t" << id << std::endl; std::cout << "所属实验室:\t" << laboratory << std::endl; std::cout << "职务:\t\t" << title << std::endl; } void TESTER::show_row() { std::cout << std::left << std::setw(8) << name; if(sex) std::cout << std::left << std::setw(8) << "男"; else std::cout << std::left << std::setw(8) << "女"; std::cout << std::left << std::setw(8) << age; std::cout << std::left << std::setw(16) << id; std::cout << std::left << std::setw(16) << laboratory; std::cout << std::left << std::setw(16) << title; std::cout << std::endl; } bool TESTER::change() { std::cout << "姓名:\t\t" ; std::string new_name; std::cin >> new_name; for(unsigned int i = 0; i < new_name.length(); i++) { if(new_name[i] >= '0' && new_name[i] <= '9') { std::cout << "输入非法,输入任意键返回\n"; return 1; } } name = new_name; std::cout << "姓别:\t\t"; std::string a; std::cin >> a; if(sex) man_sum--; else woman_sum--; if(a == "男") sex = 1, man_sum++; else sex = 0, woman_sum++; std::cout << "年龄:\t\t"; std::cin >> age; std::cout << "所属实验室:\t"; std::cin >> laboratory; std::cout << "职务:\t\t"; std::cin >> title; return 0; } #endif // TESTER_H_INCLUDED teacher.h 教师: #ifndef TEACHER_H_INCLUDED #define TEACHER_H_INCLUDED #include"common.h" class TEACHER: virtual public COMMON { protected: std::string department; std::string profession; std::string title; static int teacher_sum; public: TEACHER(std::string a = "xixi", bool b = 1, int c = 30, std::string d = "213", std::string e = "计算机与信息工程学院", std::string f = "计算机科学与技术", std::string g = "教师"); ~TEACHER(); static int get_teacher_sum(); virtual void show(); virtual void show_row(); virtual bool change(); std::string get_department(){return department;} std::string get_profession(){return profession;} std::string get_title(){return title;} }; int TEACHER::teacher_sum = 0; int TEACHER::get_teacher_sum() { return teacher_sum; } TEACHER::TEACHER(std::string a, bool b, int c, std::string d, std::string e, std::string f, std::string g): COMMON(a,b,c,d), department(e), profession(f), title(g) { teacher_sum++; } TEACHER::~TEACHER() { teacher_sum--; } void TEACHER::show() { std::cout << "教师:\n"; std::cout << "姓名:\t\t" << name << std::endl; std::cout << "姓别:\t\t"; if(sex) std::cout << "男\n"; else std::cout << "女\n"; std::cout << "年龄:\t\t" << age << std::endl; std::cout << "ID:\t\t" << id << std::endl; std::cout << "院系:\t\t" << department << std::endl; std::cout << "专业:\t\t" << profession << std::endl; std::cout << "职务:\t\t" << title << std::endl; } void TEACHER::show_row() { std::cout << std::left << std::setw(8) << name; if(sex) std::cout << std::left << std::setw(8) << "男"; else std::cout << std::left << std::setw(8) << "女"; std::cout << std::left << std::setw(8) << age; std::cout << std::left << std::setw(16) << id; std::cout << std::left << std::setw(16) << department; std::cout << std::left << std::setw(16) << profession; std::cout << std::left << std::setw(16) << title; std::cout << std::endl; } bool TEACHER::change() { std::cout << "姓名:\t\t" ; std::string new_name; std::cin >> new_name; for(unsigned int i = 0; i < new_name.length(); i++) { if(new_name[i] >= '0' && new_name[i] <= '9') { std::cout << "输入非法,输入任意键返回\n"; return 1; } } name = new_name; std::cout << "姓别:\t\t"; std::string a; std::cin >> a; if(sex) man_sum--; else woman_sum--; if(a == "男") sex = 1, man_sum++; else sex = 0, woman_sum++; std::cout << "年龄:\t\t"; std::cin >> age; std::cout << "院系:\t\t"; std::cin >> department; std::cout << "专业:\t\t"; std::cin >> profession; std::cout << "职务:\t\t"; std::cin >> title; return 0; } #endif // TEACHER_H_INCLUDED administrator.h 行政人员: #ifndef ADMINISTRATOR_H_INCLUDED #define ADMINISTRATOR_H_INCLUDED #include"common.h" class ADMINISTRATOR: virtual public COMMON { protected: std::string politics; std::string position; static int administrator_sum; public: ADMINISTRATOR(std::string a = "huhu", bool b = 1, int c = 39, std::string d = "176", std::string e = "群众", std:: string f = "社会主义新青年"); ~ADMINISTRATOR(); static int get_administrator_sum(); virtual void show(); virtual void show_row(); virtual bool change(); std::string get_politics(){return politics;} std::string get_position(){return position;} }; int ADMINISTRATOR::administrator_sum = 0; int ADMINISTRATOR::get_administrator_sum() { return administrator_sum; } ADMINISTRATOR::ADMINISTRATOR(std::string a, bool b, int c, std::string d, std::string e, std::string f): COMMON(a,b,c,d), politics(e), position(f) { administrator_sum++; } ADMINISTRATOR::~ADMINISTRATOR() { administrator_sum--; } void ADMINISTRATOR::show() { std::cout << "行政人员:\n"; std::cout << "姓名:\t\t" << name << std::endl; std::cout << "姓别:\t\t"; if(sex) std::cout << "男\n"; else std::cout << "女\n"; std::cout << "年龄:\t\t" << age << std::endl; std::cout << "ID:\t\t" << id << std::endl; std::cout << "政治面貌:\t" << politics << std::endl; std::cout << "职称:\t\t" << position << std::endl; } void ADMINISTRATOR::show_row() { std::cout << std::left << std::setw(8) << name; if(sex) std::cout << std::left << std::setw(8) << "男"; else std::cout << std::left << std::setw(8) << "女"; std::cout << std::left << std::setw(8) << age; std::cout << std::left << std::setw(16) << id; std::cout << std::left << std::setw(16) << politics; std::cout << std::left << std::setw(16) << position; std::cout << std::endl; } bool ADMINISTRATOR::change() { std::cout << "姓名:\t\t" ; std::string new_name; std::cin >> new_name; for(unsigned int i = 0; i < new_name.length(); i++) { if(new_name[i] >= '0' && new_name[i] <= '9') { std::cout << "输入非法,输入任意键返回\n"; return 1; } } name = new_name; std::cout << "姓别:\t\t"; std::string a; std::cin >> a; if(sex) man_sum--; else woman_sum--; if(a == "男") sex = 1, man_sum++; else sex = 0, woman_sum++; std::cout << "年龄:\t\t"; std::cin >> age; std::cout << "政治面貌:\t"; std::cin >> politics; std::cout << "职称:\t\t"; std::cin >> position; return 0; } #endif // ADMINISTRATOR_H_INCLUDED tea&admi.h 教师及行政人员: #ifndef TEAADMI_H_INCLUDED #define TEAADMI_H_INCLUDED #include"teacher.h" #include"administrator.h" class TEAADMI: public TEACHER, public ADMINISTRATOR { private: static int teaadmi_sum; public: TEAADMI(std::string a = "maomao", bool b = 1, int c = 59, std::string d = "0", std::string e = "计算机与信息工程学院", std::string f = "计算机科学与技术", std::string g = "教师", std::string h = "群众", std:: string i = "社会主义新青年"); ~TEAADMI(); static int get_teaadmi_sum(); virtual void show(); virtual void show_row(); virtual bool change(); }; int TEAADMI::teaadmi_sum = 0; int TEAADMI::get_teaadmi_sum() { return teaadmi_sum; } TEAADMI::TEAADMI(std::string a, bool b, int c, std::string d, std::string e, std::string f, std::string g, std::string h, std::string i): COMMON(a,b,c,d), TEACHER(a,b,c,d,e,f,g), ADMINISTRATOR(a,b,c,d,h,i) { teaadmi_sum++; } TEAADMI::~TEAADMI() { teaadmi_sum--; } void TEAADMI::show() { std::cout << "教师及行政人员:\n"; std::cout << "姓名:\t\t" << name << std::endl; std::cout << "姓别:\t\t"; if(sex) std::cout << "男\n"; else std::cout << "女\n"; std::cout << "年龄:\t\t" << age << std::endl; std::cout << "ID:\t\t" << id << std::endl; std::cout << "院系:\t\t" << department << std::endl; std::cout << "专业:\t\t" << profession << std::endl; std::cout << "职务:\t\t" << title << std::endl; std::cout << "政治面貌:\t" << politics << std::endl; std::cout << "职称:\t\t" << position << std::endl; } void TEAADMI::show_row() { std::cout << std::left << std::setw(8) << name; if(sex) std::cout << std::left << std::setw(8) << "男"; else std::cout << std::left << std::setw(8) << "女"; std::cout << std::left << std::setw(8) << age; std::cout << std::left << std::setw(16) << id; std::cout << std::left << std::setw(16) << department; std::cout << std::left << std::setw(16) << profession; std::cout << std::left << std::setw(16) << title; std::cout << std::left << std::setw(16) << politics; std::cout << std::left << std::setw(16) << position; std::cout << std::endl; } bool TEAADMI::change() { std::cout << "姓名:\t\t" ; std::string new_name; std::cin >> new_name; for(unsigned int i = 0; i < new_name.length(); i++) { if(new_name[i] >= '0' && new_name[i] <= '9') { std::cout << "输入非法,输入任意键返回\n"; return 1; } } name = new_name; std::cout << "姓别:\t\t"; std::string a; std::cin >> a; if(sex) man_sum--; else woman_sum--; if(a == "男") sex = 1, man_sum++; else sex = 0, woman_sum++; std::cout << "年龄:\t\t"; std::cin >> age; std::cout << "院系:\t\t"; std::cin >> department; std::cout << "专业:\t\t"; std::cin >> profession; std::cout << "职务:\t\t"; std::cin >> title; std::cout << "政治面貌:\t"; std::cin >> politics; std::cout << "职称:\t\t"; std::cin >> position; return 0; } #endif // TEA&ADMI_H_INCLUDED interface.h 界面: #ifndef INTERFACE_H_INCLUDED #define INTERFACE_H_INCLUDED #include"teacher.h" #include"tester.h" #include"administrator.h" #include"tea&admi.h" #include<stdio.h> #include<stdlib.h> #include<conio.h> /*----------------函数声明-------------------*/ void interface_login(); //初始界面 void interface_Manager(); //管理者界面 void staff_list(); //管理者清单 #include"myfun.h" /*----------------函数定义-------------------*/ void interface_Manager() //管理界面 { int n=1; while(n) { system("cls"); std::cout << "------------欢迎来到只有神知道的领域 o(*≧▽≦)ツ----------\n"; std::cout << "-----------------------------------------------------------\n"; std::cout << "-----------------------------------------------------------\n"; std::cout << "------------- 输入1 添加信息 -------------\n"; std::cout << "------------- 输入2 查询信息 -------------\n"; std::cout << "------------- 输入3 浏览信息 -------------\n"; std::cout << "------------- 输入4 修改信息 -------------\n"; std::cout << "------------- 输入5 删除信息 -------------\n"; std::cout << "------------- 输入6 统计信息 -------------\n"; std::cout << "------------- 输入0 返回上一级 -------------\n"; std::cout << "-----------------------------------------------------------\n"; std::cout << "-----------------------------------------------------------\n"; std::cin >> n; switch(n) { case 1:Add_information();break; case 2: { int a = 1; if(!Query_information()) break; while(a) { std::cout << "输入1 修改信息\n"; std::cout << "输入2 删除信息\n"; std::cout << "输入0 返回上一级\n"; std::cin >> a; switch(a) { case 1:Edit_information(); a = 0; break; case 2:Delete_information(); a= 0; break; } } break; } case 3: { int a=1; while(a) { Browse_information(); std::cout << "输入1 修改信息\n"; std::cout << "输入2 删除信息\n"; std::cout << "输入0 返回上一级\n"; std::cin >> a; switch(a) { case 1:Edit_information(); break; case 2:Delete_information(); break; } } break; } case 4:Edit_information(); break; case 5:Delete_information(); break; case 6:count_information(); break; } } } void interface_login() //登入界面 { int n=1; while(n) { system("cls"); std::cout << "----------欢迎进入高校人员信息管理系统 o(*≧▽≦)ツ--------\n"; std::cout << "-----------------------------------------------------------\n"; std::cout << "-----------------------------------------------------------\n"; std::cout << "------------- 输入1 管理员账号登入 -------------\n"; std::cout << "------------- 输入2 查询信息 -------------\n"; std::cout << "------------- 输入3 浏览信息 -------------\n"; std::cout << "------------- 输入4 统计信息 -------------\n"; std::cout << "------------- 输入5 观看制作信息 -------------\n"; std::cout << "------------- 输入0 关闭系统 -------------\n"; std::cout << "-----------------------------------------------------------\n"; std::cout << "-----------------------------------------------------------\n"; std::cin >> n; switch(n) { case 1:login(); break; case 2:if(Query_information()) std::cout << "输入任意键,返回上一级\n", getch(); break; case 3:Browse_information(); std::cout << "输入任意键,返回上一级\n"; getch(); break; case 4:count_information(); break; case 5:staff_list(); break; } } } void staff_list() //制作人员名单 { system("cls"); std::cout << "-----------------------------------------------------------\n"; std::cout << "-----------------------------------------------------------\n"; std::cout << "--------------Include the following members----------------\n"; std::cout << "-------------- wzy ----------------\n"; std::cout << "-------------- ToRe ----------------\n"; std::cout << "-----------------------------------------------------------\n"; std::cout << "-----------------------------------------------------------\n\n\n"; std::cout << "\n输入任意键返回主菜单…\n"; getch(); } #endif // INTERFACE_H_INCLUDED myfun.h 主要功能实现: #ifndef MYFUN_H_INCLUDED #define MYFUN_H_INCLUDED #include<vector> #include<map> #include<fstream> /*----------------成员声明-------------------*/ std::multimap<std::string, COMMON *> sear; std::vector<TESTER*> tester; std::vector<TEACHER*> teacher; std::vector<ADMINISTRATOR*> administrator; std::vector<TEAADMI*> teaadmi; /*----------------函数声明-------------------*/ void Information_load(); //信息加载 void room_delete(); //释放空间 void login(); //登入函数 void Add_information(); //添加信息 bool Query_information(); //显示查询信息 void Browse_information(); //浏览信息 void Edit_information(); //修改信息 void Delete_information(); //删除信息 void count_information(); //统计信息 /*----------------函数定义-------------------*/ void Information_load() //信息加载 { std::ifstream in; in.open("实验员.txt", std::ios::in); std::string name, id; int age; bool sex; while(in >> name) { std::string laboratory, title; in >> sex >> age >> id >> laboratory >> title; TESTER *t = new TESTER(name,sex,age,id,laboratory,title); tester.push_back(t); sear.insert(make_pair(name, t)); sear.insert(make_pair(id, t)); } in.close(); in.open("教师.txt", std::ios::in); while(in >> name) { std::string department, profession, title; in >> sex >> age >> id >> department >> profession >> title; TEACHER *t = new TEACHER(name,sex,age,id,department,profession,title); teacher.push_back(t); sear.insert(make_pair(name, t)); sear.insert(make_pair(id, t)); } in.close(); in.open("行政人员.txt", std::ios::in); while(in >> name) { std::string politics, position; in >> sex >> age >> id >> politics >> position; ADMINISTRATOR *t = new ADMINISTRATOR(name,sex,age,id,politics,position); administrator.push_back(t); sear.insert(make_pair(name, t)); sear.insert(make_pair(id, t)); } in.close(); in.open("教师&行政人员.txt", std::ios::in); while(in >> name) { std::string department, profession, title, politics, position; in >> sex >> age >> id >> department >> profession >> title >> politics >> position; TEAADMI *t = new TEAADMI(name,sex,age,id,department,profession,title,politics,position); teaadmi.push_back(t); sear.insert(make_pair(name, t)); sear.insert(make_pair(id, t)); } } void room_delete() //释放空间 { for(auto iter:tester) delete iter; for(auto iter:teacher) delete iter; for(auto iter:administrator) delete iter; for(auto iter:teaadmi) delete iter; } void login() //登入函数 { std::string com; system("cls"); std::cout << "请输入密码\n"; getchar(); std::getline(std::cin,com); if(com == "bokuwasinnsekainokamitonaru") interface_Manager(); else { std::cout << "密码错误,输入任意键返回上一级\n"; getch(); } } void Add_information()//添加信息 { system("cls"); std::cout << "请输入添加类型\n1:实验员\t2:教师\t\t3:行政人员\t4:教师及行政人员\n"; int flag; std::cin >> flag; std::string name, se, id; int age; bool sex = 0; std::cout << "ID:\t\t"; std::cin >> id; for(unsigned int i = 0; i < id.length(); i++) { if(id[i] < '0' || id[i] > '9') { std::cout << "输入非法,输入任意键返回\n"; getch(); return; } } std::multimap<std::string, COMMON *>::iterator beg, en; beg = sear.lower_bound(id); en = sear.upper_bound(id); if(beg != en) { std::cout << "此ID已存在,输入任意键返回\n"; getch(); return; } std::cout << "姓名:\t\t"; std::cin >> name; for(unsigned int i = 0; i < name.length(); i++) { if(name[i] >= '0' && name[i] <= '9') { std::cout << "输入非法,输入任意键返回\n"; getch(); return; } } std::cout << "性别:\t\t"; std::cin >> se; if(se == "男") sex = 1; std::cout << "年龄:\t\t"; std::cin >> age; if(flag == 1) { std::string laboratory, title; std::cout << "实验室名称:\t"; std::cin >> laboratory; std::cout << "职务:\t\t"; std::cin >> title; TESTER *t = new TESTER(name,sex,age,id,laboratory,title); tester.push_back(t); sear.insert(make_pair(name, t)); sear.insert(make_pair(id, t)); std::ofstream out; out.open("实验员.txt", std::ios::app); out << name << " " << sex << " " << age << " " << id << " "; out << laboratory << " " << title << std::endl; out.close(); } if(flag == 2) { std::string department, profession, title; std::cout << "院系:\t\t"; std::cin >> department; std::cout << "专业:\t\t"; std::cin >> profession; std::cout << "职务:\t\t"; std::cin >> title; TEACHER *t = new TEACHER(name,sex,age,id,department,profession,title); teacher.push_back(t); sear.insert(make_pair(name, t)); sear.insert(make_pair(id, t)); std::ofstream out; out.open("教师.txt", std::ios::app); out << name << " " << sex << " " << age << " " << id << " "; out << department << " " << profession << " " << title << std::endl; out.close(); } if(flag == 3) { std::string politics, position; std::cout << "政治面貌:\t"; std::cin >> politics; std::cout << "职称:\t\t"; std::cin >> position; ADMINISTRATOR *t = new ADMINISTRATOR(name,sex,age,id,politics,position); administrator.push_back(t); sear.insert(make_pair(name, t)); sear.insert(make_pair(id, t)); std::ofstream out; out.open("行政人员.txt", std::ios::app); out << name << " " << sex << " " << age << " " << id << " "; out << politics << " " << position << std::endl; out.close(); } if(flag == 4) { std::string department, profession, title, politics, position; std::cout << "院系:\t\t"; std::cin >> department; std::cout << "专业:\t\t"; std::cin >> profession; std::cout << "职务:\t\t"; std::cin >> title; std::cout << "政治面貌:\t"; std::cin >> politics; std::cout << "职称:\t\t"; std::cin >> position; TEAADMI *t = new TEAADMI(name,sex,age,id,department,profession,title,politics,position); teaadmi.push_back(t); sear.insert(make_pair(name, t)); sear.insert(make_pair(id, t)); std::ofstream out; out.open("教师&行政人员.txt", std::ios::app); out << name << " " << sex << " " << age << " " << id << " "; out << department << " " << profession << " " << title << " "; out << politics << " " << position << std::endl; out.close(); } std::cout << "注册成功,输入任意键返回\n"; getch(); } void Delete_information() //删除信息 { std::cout << "输入目标ID以确认\n"; std::string aid; std::cin >> aid; for(unsigned int i = 0; i < aid.length(); i++) { if(aid[i] < '0' || aid[i] > '9') { std::cout << "输入非法,输入任意键返回\n"; getch(); return; } } std::multimap<std::string, COMMON *>::iterator beg, en, iter; beg = sear.lower_bound(aid); en = sear.upper_bound(aid); if(beg == en) { std::cout << "目标不存在,输入任意键返回\n"; getch(); return; } std::string aid_name = beg -> second -> get_name(); sear.erase(beg); beg = sear.lower_bound(aid_name); en = sear.upper_bound(aid_name); for(iter = beg; iter != en; ++iter) if(iter -> second -> get_id() == aid) {sear.erase(iter); break;} bool flag = 0; std::ofstream out; out.open("实验员.txt", std::ios::out); for(std::vector<TESTER*>::iterator it = tester.begin(); it != tester.end();) { if((*it) -> get_id() == aid){flag = 1; delete (*it); it = tester.erase(it); continue;} out << (*it) -> get_name() << " " << (*it) -> get_sex() << " "; out << (*it) -> get_age() << " " << (*it) -> get_id() << " "; out << (*it) -> get_laboratory() << " " << (*it) -> get_title() << std::endl; ++it; } out.close(); if(flag) {std::cout << "删除成功,输入任意键返回\n"; getch(); return;} out.open("教师.txt", std::ios::out); for(std::vector<TEACHER*>::iterator it = teacher.begin(); it != teacher.end();) { if((*it) -> get_id() == aid){flag = 1; delete (*it); it = teacher.erase(it); continue;} out << (*it) -> get_name() << " " << (*it) -> get_sex() << " "; out << (*it) -> get_age() << " " << (*it) -> get_id() << " "; out << (*it) -> get_department() << " " << (*it) -> get_profession() << " " << (*it) -> get_title() << std::endl; it++; } out.close(); if(flag) {std::cout << "删除成功,输入任意键返回\n"; getch(); return;} out.open("行政人员.txt", std::ios::out); for(std::vector<ADMINISTRATOR*>::iterator it = administrator.begin(); it != administrator.end();) { if((*it) -> get_id() == aid){flag = 1; delete (*it); it = administrator.erase(it); continue;} out << (*it) -> get_name() << " " << (*it) -> get_sex() << " "; out << (*it) -> get_age() << " " << (*it) -> get_id() << " "; out << (*it) -> get_politics() << " " << (*it) -> get_position() << std::endl; it++; } out.close(); if(flag) {std::cout << "删除成功,输入任意键返回\n"; getch(); return;} out.open("教师&行政人员.txt", std::ios::out); for(std::vector<TEAADMI*>::iterator it = teaadmi.begin(); it != teaadmi.end();) { if((*it) -> get_id() == aid){flag = 1; delete (*it); it = teaadmi.erase(it); continue;} out << (*it) -> get_name() << " " << (*it) -> get_sex() << " "; out << (*it) -> get_age() << " " << (*it) -> get_id() << " "; out << (*it) -> get_department() << " " << (*it) -> get_profession() << " " << (*it) -> get_title() << " "; out << (*it) -> get_politics() << " " << (*it) -> get_position() << std::endl; ++it; } out.close(); std::cout << "删除成功,输入任意键返回\n"; getch(); } void Edit_information() //修改信息 { std::cout << "输入目标ID以确认\n"; std::string aid; std::cin >> aid; for(unsigned int i = 0; i < aid.length(); i++) { if(aid[i] < '0' || aid[i] > '9') { std::cout << "输入非法,输入任意键返回\n"; getch(); return; } } std::multimap<std::string, COMMON *>::iterator beg, en, iter; beg = sear.lower_bound(aid); en = sear.upper_bound(aid); if(beg == en) { std::cout << "目标不存在,输入任意键返回\n"; getch(); return; } system("cls"); bool flag = 0; std::ofstream out; out.open("实验员.txt", std::ios::out); for(auto iter:tester) { if(iter -> get_id() == aid) { iter -> show(), std::cout << "\n\n根据提示输入修改信息\n\n"; while(iter -> change()) { system("cls"); iter -> show(); std::cout << "输入非法,请重新输入\n"; } flag = 1; } out << iter -> get_name() << " " << iter -> get_sex() << " "; out << iter -> get_age() << " " << iter -> get_id() << " "; out << iter -> get_laboratory() << " " << iter -> get_title() << std::endl; } out.close(); if(flag) {std::cout << "修改成功,输入任意键返回\n"; getch(); return;} out.open("教师.txt", std::ios::out); for(auto iter:teacher) { if(iter -> get_id() == aid) { iter -> show(), std::cout << "\n\n根据提示输入修改信息\n\n"; while(iter -> change()) { system("cls"); iter -> show(); std::cout << "输入非法,请重新输入\n"; } flag = 1; } out << iter -> get_name() << " " << iter -> get_sex() << " "; out << iter -> get_age() << " " << iter -> get_id() << " "; out << iter -> get_department() << " " << iter -> get_profession() << " " << iter -> get_title() << std::endl; } out.close(); if(flag) {std::cout << "修改成功,输入任意键返回\n"; getch(); return;} out.open("行政人员.txt", std::ios::out); for(auto iter:administrator) { if(iter -> get_id() == aid) { iter -> show(), std::cout << "\n\n根据提示输入修改信息\n\n"; while(iter -> change()) { system("cls"); iter -> show(); std::cout << "输入非法,请重新输入\n"; } flag = 1; } out << iter -> get_name() << " " << iter -> get_sex() << " "; out << iter -> get_age() << " " << iter -> get_id() << " "; out << iter -> get_politics() << " " << iter -> get_position() << std::endl; } out.close(); if(flag) {std::cout << "修改成功,输入任意键返回\n"; getch(); return;} out.open("教师&行政人员.txt", std::ios::out); for(auto iter:teaadmi) { if(iter -> get_id() == aid) { iter -> show(), std::cout << "\n\n根据提示输入修改信息\n\n"; while(iter -> change()) { system("cls"); iter -> show(); std::cout << "输入非法,请重新输入\n"; } flag = 1; } out << iter -> get_name() << " " << iter -> get_sex() << " "; out << iter -> get_age() << " " << iter -> get_id() << " "; out << iter -> get_department() << " " << iter -> get_profession() << " " << iter -> get_title() << " "; out << iter -> get_politics() << " " << iter -> get_position() << std::endl; } out.close(); std::cout << "修改成功,输入任意键返回\n"; getch(); } bool Query_information() //查询函数 { system("cls"); std::cout << "输入目标姓名或ID以查询\n"; std::string aid; std::cin >> aid; std::multimap<std::string, COMMON *>::iterator beg, en, iter; beg = sear.lower_bound(aid); en = sear.upper_bound(aid); if(beg == en) { std::cout << "查询结果为空,输入任意键返回\n"; getch(); return 0; } for(iter = beg; iter != en; ++iter) { iter -> second -> show(); std::cout << std::endl; } return 1; } void Browse_information() //浏览函数 { system("cls"); std::cout << "-------------------实验员-------------------\n"; std::cout << "姓名\t" << "性别\t" << "年龄\t" << "ID\t\t" << "实验室名称\t" << "职务\n"; for(auto iter:tester) iter -> show_row(); std::cout << "\n------------------行政人员------------------\n"; std::cout << "姓名\t" << "性别\t" << "年龄\t" << "ID\t\t" << "政治面貌\t" << "职称\n"; for(auto iter:administrator) iter -> show_row(); std::cout << "\n--------------------教师--------------------\n"; std::cout << "姓名\t" << "性别\t" << "年龄\t" << "ID\t\t" << "院系\t\t" << "专业\t\t" << "职务\n"; for(auto iter:teacher) iter -> show_row(); std::cout << "\n-----------------行政人员&教师--------------\n"; std::cout << "姓名\t" << "性别\t" << "年龄\t" << "ID\t\t" << "政治面貌\t" << "职称\t\t" << "院系\t\t" << "专业\t\t" << "职务\n"; for(auto iter:teaadmi) iter -> show_row(); } void count_information() //统计信息 { system("cls"); std::cout << "员工总人数:\t\t" << COMMON::get_person_sum() << std::endl; std::cout << "男性人数:\t\t" << COMMON::get_man_sum() << std::endl; std::cout << "女性人数:\t\t" << COMMON::get_woman_sum() << std::endl; std::cout << "教师人数:\t\t" << TEACHER::get_teacher_sum() << std::endl; std::cout << "实验员人数:\t\t" << TESTER::get_tester_sum() << std::endl; std::cout << "行政管理人员人数:\t" << ADMINISTRATOR::get_administrator_sum() << std::endl; std::cout << "行政管理人员&教师人数:\t" << TEAADMI::get_teaadmi_sum() << std::endl; std::cout << "\n\n输入任意键返回上一级\n"; getch(); } #endif // MYFUN_H_INCLUDED main.cpp 主函数: #include"interface.h" int main() { Information_load(); //加载信息 interface_login(); //首界面 room_delete(); //释放空间 // count_information(); return 0; }

无法引用 函数 "std::basic_fstream<_Elem,

#include "stdafx.h" #include "iostream" #include "fstream" #include "stdlib.h" using namespace std; void ord(fstream f1) { if (!f1) { cerr << "文件打不开" << endl; exit(1); } } void ffout() { fstream f1("E:\\大中华", ios::out | ios::binary | ios::ate|ios::trunc); ord(f1); f1 << "我爱我家" << endl; f1.close(); } void ffint() { char a[100]; fstream f1("E:\\大中华", ios::in | ios::binary); while (!f1.eof()) { f1.getline(a, 70); cout << a << endl; } f1.close(); } void main() { ffout(); ffint(); }

C++或者C编写一个能复制任何二进制文件的程序,但是根本写不出来,求大神

问题是很简单啦,虽然看起来简单,想起来简单,但是但是整整用起来的时候发现根本无法实现。无论是用C++的fstream中的文件流,还是用C的stdlib的FILE都不行,exe文件可以打开,可以复制,但是复制之后的文件还有复制之前的文件内容根本不一样,现在贴上来的是主要的代码,用的是ifstream的,FILE我也试过了,同样没有用,而且,复制出来的结果比不上这个完整 void MainProcessor::read() { std::cout << " Please Insert File Name(*.*) " << std::endl; std::cin >> file_name; std::ifstream in; in.open(file_name, std::ios::binary | std::ios::in | std::ios::app, _SH_DENYNO); in.read((char*)a, 100000000); int b = in.gcount(); if (length_of_file > b) { length_of_file = b; } if (b == 0) { std::cout << "No such file or the file is empty,try again" << std::endl; is_read_file = false; } else { std::cout << "Read Success!" << std::endl; is_read_file = true; std::cout << std::endl; std::cout << "There are " << b << "chars in the file" << std::endl; std::cout << std::endl; } in.close(); } 这里是读入文件 void MainProcessor::write() { std::cout << "Your new locked_file_name?(*.*)" << std::endl; std::cin >> lock_it_file_name; std::ofstream out(lock_it_file_name); if (out.is_open()) { out.write((char*)a, (length_of_file)*sizeof(char)); out.close(); } std::ifstream in; in.open(lock_it_file_name, std::ios::binary | std::ios::in | std::ios::app, _SH_DENYNO); in.read((char*)compare, 100000000); int b = in.gcount(); } 上面是写入的文件 ![这里是调试的时候可以看见的,很明显到这里就出现了区别,当然问题还不止这点](https://img-ask.csdn.net/upload/201512/13/1450013224_6221.png) 在附件上由我复制之前(B1-B.txt,是exe文件,为了防止风险,特意改成txt文件,更改后缀名之后便可以打开),后面的是复制之后的文件(asd.txt,同上) 文件无法添加到附件,还请各位劳心到百度盘去下载一下 [两个文件](http://pan.baidu.com/s/1mhql76K "打开之后可以获得上面两个文件,还请大神多多帮忙") 我是调试了好长时间无论如何调试不出来了- -,求大神帮助啊!

关于书店的一个小程序,c++写的。.大家帮忙看看怎么运行不了???

代码可以在这儿粘贴 #include <iostream> #include <string> using namespace std; class Sales_data { friend std::istream& operator>>(std::istream&, Sales_data&); friend std::ostream& operator<<(std::ostream&, const Sales_data&); friend bool operator < (const Sales_data&,const Sales_data&); friend bool operator ==(const Sales_data&, const Sales_data&); public: Sales_data(){ default; } Sales_data(const std::string &book) :bookNo(book){ } Sales_data(std::istream &is) { is >> *this; } public: Sales_data& operator +=(const Sales_data&); std::string isbn() const{ return bookNo; } private: std::string bookNo; unsigned units_sold = 0; double sellingprice = 0.0; double saleprice = 0.0; double discount = 0.0; }; inline bool comparaIsbn(const Sales_data &lhs, const Sales_data &rhs) {return lhs.isbn() == rhs.isbn();} Sales_data operator + (const Salea_data&, const Salea_data&); inline bool operator==(const Sales_data&lhs, const Sales_data&rhs) { return lhs.units_sold == rhs.units_sold&& lhs.sellingprice == rhs.sellingprice&& lhs.saleprice == rhs.saleprice&& lhs.isbn() == rhs.isbn(); } inline bool operator!=(const Sales_data&lhs, const Sales_data&rhs) { return!(lhs == rhs); } Sales_data& Sales_data::operator+=(const Sales_data&rhs) { units_sold += rhs.units_sold; saleprice = (rhs.saleprice*rhs.units_sold + saleprice*units_sold) / (rhs.units_sold + units_sold); if (sellingprice != 0) discount = saleprice / sellingprice; return *this; } Sales_data operator+(const Sales_data&lhs, const Sales_data&rhs) { Sales_data ret(lhs); ret += rhs; return ret; } std::istream&operator>>(std::istream& in, sales_data& s) { in >> s.bookNo >> s.units_sold >> s.sellingprice >> s.saleprice; if (in && s.sellingprice != 0) s.discount = s.saleprice / s.sellingprice; else s = Sales_data(); return in; } std::ostream& operator<<(std::ostream&out, const Sales_data&s) { out << s.isbn() << "" << s.units_sold << "" << s.sellingprice << "" << s.saleprice << "" << s.discount; return out; } int main() { Sales_data book; std::cout << "请输入销售记录:" << std::endl; while (std::cin >> book){ std::cout << "ISBN、售出本数、原始价格、实售价格、折扣为" << book << std::endl; } Sales_data trans1, trans2; std::cout << "请输入两条ISBN相同的销售记录:" << std::endl; std::cin >> trans1 >> trans2; if (comparaIsbn(trans1, trans2)) std::cout << "汇总信息:ISBN、售出本数、原始价格、实售价格、折扣为" << trans1 + trans2 << std::endl; else std::cout << "两条销售记录的ISBN不同" << std::endl; Sales_data total, trans; std::cout << "请输入几条ISBN相同的销售记录:" << std::endl; if (std::cin >> total){ while (std::cin>>trans) if (compareIsbn(total, trans)) total += trans; else{ std::cout << "当前书籍ISBN不同" << std::endl; break; } std::cout << "有效汇总信息:ISBN、售出本数、原始价格、实售价格、折扣为" << total << std::endl; } else{ std::cout << "没有数据" << std::endl; return -1; } int num = 1; std::cout << "请输入若干销售记录:" << std::endl; if (std:; cin >> trans1){ while (std::cin>>trans2) if (comparaIsbn(trans1, trans2)) num++; else{ std::cout << trans1.isbn() << "共有" << num << "条销售记录" << std::endl; trans1 == trans2; num = 1; } std::cout << trans1.isbn() << "共有" << num << "条销售记录" << std::endl; } else{ std::cout << "没有数据" << std::endl; return -1; } return 0; }

C++中使用二进制文件保存和读取结构体的问题

为了了解书中的代码,自己编写了下面这段简单的测试代码。 #include<iostream> #include<fstream> #include<string> struct Test { int key; std::string data; }; int main() { Test test; test.key = 1; test.data = "Anthony"; std::ofstream fout("D:\\Data.dat", std::ios_base::out | std::ios_base::binary); fout.write((char*)&test, sizeof Test); fout.close(); std::ifstream fin("D:\\Data.dat", std::ios_base::in | std::ios_base::app | std::ios_base::binary); Test test_1; fin.seekg(0); fin.read((char*)&test_1, sizeof Test); std::cout << test_1.key << std::endl; std::cout << test_1.key << std::endl; std::cout << test_1.data << std::endl; std::cout << test_1.data << std::endl; system("pause"); return 0; } 这段代码编译没有任何问题,但是出现了运行错误(CE)。而且经调试发现错误实在程序执行return 0;之后才发生的。程序运行截图如下。 运行代码后如下: ![运行代码后](https://img-ask.csdn.net/upload/201803/22/1521718446_18679.png) 再按任意键后如下: ![按任意键后](https://img-ask.csdn.net/upload/201803/22/1521718827_396761.jpg) **调试后发现的异常为:**0x00088538 处(位于 FileStruct.exe 中)引发的异常: 0xC0000005: 写入位置 0xDDDDDDDD 时发生访问冲突。****

模板类中重载<<运算符,声明在类中,定义在类外,编译错误。

#include<iostream> using namespace std; template <typename T> class A{ friend A operator- (A& m, A&n){ A t(m.a - n.a, m.b - n.b); return t; } friend ostream & operator<< <T> (ostream &out, A &t); public: A(){ } A (T a, T b); A operator + (A &m); void show(); private: T a; T b; }; template <typename T> ostream & operator<< (ostream &out, A<T> &t){ out << t.a << " + " << t.b << "i"; return out; } template <typename T> A<T>::A (T a, T b){ this->a = a; this->b = b; cout << "init" << endl; } template <typename T> void A<T>::show(){ cout << "a:" << a << "b:" << b << endl; } template <typename T> A<T> A<T>::operator+ (A<T> &m){ A t(a + m.a, b + m.b); return t; } int main(){ A<int> t(1,2); // cout << t << endl; // A<int> t2(3,4); // A<int> t3 = t + t2; // cout << t3 << endl; // t3 = t - t2; // cout << t3 << endl; return 0; } g++编译 t2.cpp: In instantiation of ‘class A<int>’: t2.cpp:48:10: required from here t2.cpp:10:19: error: template-id ‘operator<< <int>’ for ‘std::ostream& operator<<(std::ostream&, A<int>&)’ does not match any template declaration friend ostream & operator<< <T> (ostream &out, A &t); ^ init

C++,书店的一个小程序,有错误

![图片说明](https://img-ask.csdn.net/upload/201507/01/1435713669_105198.png) #include <iostream> #include <string> using namespace std; class Sales_data { friend std::istream& operator>>(std::istream&, Sales_data&); friend std::ostream& operator<<(std::ostream&, const Sales_data&); friend bool operator < (const Sales_data&,const Sales_data&); friend bool operator ==(const Sales_data&, const Sales_data&); public: Sales_data(){ default; } Sales_data(const std::string &book) :bookNo(book){ } Sales_data(std::istream &is) { is >> *this; } public: Sales_data& operator +=(const Sales_data&); std::string isbn() const{ return bookNo; } private: std::string bookNo; unsigned units_sold = 0; double sellingprice = 0.0; double saleprice = 0.0; double discount = 0.0; }; inline bool comparaIsbn(const Sales_data &lhs, const Sales_data &rhs) {return lhs.isbn() == rhs.isbn();} Sales_data operator + (const Salea_data&, const Salea_data&); inline bool operator==(const Sales_data&lhs, const Sales_data&rhs) { return lhs.units_sold == rhs.units_sold&& lhs.sellingprice == rhs.sellingprice&& lhs.saleprice == rhs.saleprice&& lhs.isbn() == rhs.isbn(); } inline bool operator!=(const Sales_data&lhs, const Sales_data&rhs) { return!(lhs == rhs); } Sales_data& Sales_data::operator+=(const Sales_data&rhs) { units_sold += rhs.units_sold; saleprice = (rhs.saleprice*rhs.units_sold + saleprice*units_sold) / (rhs.units_sold + units_sold); if (sellingprice != 0) discount = saleprice / sellingprice; return *this; } Sales_data operator+(const Sales_data&lhs, const Sales_data&rhs) { Sales_data ret(lhs); ret += rhs; return ret; } std::istream&operator>>(std::istream& in, sales_data& s) { in >> s.bookNo >> s.units_sold >> s.sellingprice >> s.saleprice; if (in && s.sellingprice != 0) s.discount = s.saleprice / s.sellingprice; else s = Sales_data(); return in; } std::ostream& operator<<(std::ostream&out, const Sales_data&s) { out << s.isbn() << "" << s.units_sold << "" << s.sellingprice << "" << s.saleprice << "" << s.discount; return out; } int main() { Sales_data book; std::cout << "请输入销售记录:" << std::endl; while (std::cin >> book){ std::cout << "ISBN、售出本数、原始价格、实售价格、折扣为" << book << std::endl; } Sales_data trans1, trans2; std::cout << "请输入两条ISBN相同的销售记录:" << std::endl; std::cin >> trans1 >> trans2; if (comparaIsbn(trans1, trans2)) std::cout << "汇总信息:ISBN、售出本数、原始价格、实售价格、折扣为" << trans1 + trans2 << std::endl; else std::cout << "两条销售记录的ISBN不同" << std::endl; Sales_data total, trans; std::cout << "请输入几条ISBN相同的销售记录:" << std::endl; if (std::cin >> total){ while (std::cin>>trans) if (compareIsbn(total, trans)) total += trans; else{ std::cout << "当前书籍ISBN不同" << std::endl; break; } std::cout << "有效汇总信息:ISBN、售出本数、原始价格、实售价格、折扣为" << total << std::endl; } else{ std::cout << "没有数据" << std::endl; return -1; } int num = 1; std::cout << "请输入若干销售记录:" << std::endl; if (std:; cin >> trans1){ while (std::cin>>trans2) if (comparaIsbn(trans1, trans2)) num++; else{ std::cout << trans1.isbn() << "共有" << num << "条销售记录" << std::endl; trans1 == trans2; num = 1; } std::cout << trans1.isbn() << "共有" << num << "条销售记录" << std::endl; } else{ std::cout << "没有数据" << std::endl; return -1; } return 0; }

boost异步通信,async_read_some始终接收不到数据

我写了最简单boost异步通信例子,async_read_some始终接收不到数据。接收数据长度始终0,打印empty。甚至客户端断开连接后,仍打印empty,服务端对连接断开无反应。 boost版本为1_69。客户端代码,发送数据功能。服务端代码,async_read_some接收数据功能,如下: ``` class clients { public: clients(std::string str_address,int nport,int id_val) :m_ep(boost::asio::ip::address::from_string(str_address.c_str()), nport), _id(id_val) { start(); } void run() { m_io.run(); } void start() { boost::shared_ptr<boost::asio::ip::tcp::socket>sock(new boost::asio::ip::tcp::socket(m_io)); sock->async_connect(m_ep,boost::bind(&clients::conn_handler,this,boost::asio::placeholders::error,sock)); } void conn_handler(const boost::system::error_code& ec,boost::shared_ptr<boost::asio::ip::tcp::socket> sock) { if(ec) { std::cout << "id: " << _id << " connect wrong" << std::endl; return; } std::cout << "id: " << _id << " connect right to address:" << sock->remote_endpoint().address() << std::endl; sendtimer_=std::make_shared<boost::asio::deadline_timer>(m_io); sendtimer_->expires_from_now(boost::posix_time::milliseconds(500)); sendtimer_->async_wait(boost::bind(&clients::do_write,this,sock)); } void do_write(boost::shared_ptr<boost::asio::ip::tcp::socket> sock) { char sz_send[512]={0}; sprintf(sz_send,"%d_hello",_id); m_buf.clear(); for(int i=0; i<strlen(sz_send); i++) { m_buf.push_back(sz_send[i]); } sock->async_write_some(boost::asio::buffer(m_buf),boost::bind(&clients::write_handler,this,boost::asio::placeholders::error,sock)); } void write_handler(const boost::system::error_code& ec,boost::shared_ptr<boost::asio::ip::tcp::socket> sock) { if(ec) { std::cout << "id: " << _id <<" connect disconnect" << std::endl; } else { sendtimer_->expires_from_now(boost::posix_time::milliseconds(500)); sendtimer_->async_wait(boost::bind(&clients::do_write,this,sock)); } } private: boost::asio::io_service m_io; boost::asio::ip::tcp::endpoint m_ep; int _id; std::vector<char> m_buf; std::shared_ptr<boost::asio::deadline_timer> sendtimer_; }; int main(int argc, char** argv) { int id_val = 0; if(argc>1) { char* ch_val = argv[1]; id_val = atoi(ch_val); } int nport = TARGET_VALUE_PORT; std::string str_address = TARGET_VALUE_IP; std::cout << "id: " << id_val << " client start" << std::endl; clients cl(str_address, nport, id_val); cl.run(); std::cout << "id: " << id_val << " client end" << std::endl; return 0; } ``` ``` class servers { public: servers(boost::asio::io_service& io_ser, int nport): m_acceptor(io_ser, boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), nport)) { accept(); } void accept() { std::cout << "prepare accept" << std::endl; boost::shared_ptr<boost::asio::ip::tcp::socket> sock( new boost::asio::ip::tcp::socket(m_acceptor.get_io_service()) ); m_acceptor.async_accept(*sock, boost::bind(&servers::accept_handler, this, boost::asio::placeholders::error, sock)); } void accept_handler(const boost::system::error_code& ec, boost::shared_ptr<boost::asio::ip::tcp::socket> sock) { if(ec) { return; } std::cout<< sock->remote_endpoint().address() << std::endl; sock->async_read_some(boost::asio::buffer(m_buf), boost::bind(&servers::read_handler, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred, sock)); accept(); } void read_handler(const boost::system::error_code& ec, std::size_t bytes_transferred, boost::shared_ptr<boost::asio::ip::tcp::socket> sock) { if(ec) { std::cout << "error" << std::endl; return; } if(bytes_transferred==0) { std::cout << "empty" << std::endl; } else { std::string tmpstr(m_buf.begin(), m_buf.end()); if(!tmpstr.empty()) { std::cout << "Recv Data" << tmpstr << std::endl; } m_buf.clear(); } sock->async_read_some(boost::asio::buffer(m_buf), boost::bind(&servers::read_handler, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred, sock)); } private: boost::asio::ip::tcp::acceptor m_acceptor; std::vector<char> m_buf; }; int main(int argc, char** argv) { boost::asio::io_service io_service; int nport = LISTEN_VALUE_PORT; servers srv(io_service, nport); io_service.run(); return 0; } ```

关于select函数的一些疑问

想做一个监控文件的小功能,文件是FIFO类型,可能被写入0或者1,我要做的就是监控这个文件,如果被更新了就把值读出来。   用到select函数,但出现一些不太好理解的现象。   1. 每次select之前,好像都需要设置一下timeout时间,比如下面程序如果把时间设置放在while前,那么将会狂打印"once"。   2. 程序执行时,一开始“once"的打印差不多1s一次。在另一个终端输入:echo -n 0 > has_sd_card 之后,“once"有事疯狂打印了,timeout设置失效了?还是说我的echo -n 0 > has_sd_card导致stdin可读了,但是已经被重定向到文件了,没想明白。   求解答 程序源码如下: ``` // Linux include #include <fcntl.h> #include <unistd.h> #include <time.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/ioctl.h> #include <sys/time.h> #include <stdio.h> #include <iostream> int main() { int mdevFd = -1; mdevFd = open("has_sd_card", O_RDONLY|O_NONBLOCK); if (mdevFd < 0) { std::cout << "Open file failed." << std::endl; return -1; } std::cout << mdevFd << std::endl; int ret; char value; fd_set rd; struct timeval tv; while (true) { FD_ZERO(&rd); FD_SET(mdevFd, &rd); tv.tv_sec = 0; tv.tv_usec = 1000000; /* timeout 1000 ms */ std::cout << "1" << std::endl; ret = select(mdevFd + 1, &rd, NULL, NULL, &tv); std::cout << "2" << std::endl; if (ret > 0 && read(mdevFd, &value, sizeof(char)) > 0) { std::cout << "File updated, value = " << value << std::endl; } std::cout << "once" << std::endl; } close(mdevFd); return 0; } ```

VS2010读取txt文件内容后应用JSON解析

vs2010读取txt文件后,放到字符串中,后对该字符串JSON解析,但是就是不对呀,可是程序可以对程序中字符串进行JSON解析 程序如下: #include <iostream> #include <string> #include "json\json.h" #include <iomanip> #include <fstream> using namespace std; int main() { Json::Reader reader;//json解析 Json::Value value;//表示一个json格式的对象 char buffer[1000]; //char buffer[256]; ifstream myfile ("c:\\a.txt"); int i=0,j=0; while (! myfile.eof() ) { myfile.getline (buffer,100); std::string strValue=buffer; //std::string strValue="{\"name\":\"中国\",\"provinces\":[{\"name\":\"黑龙江\"},{\"citys\":\"佳木斯\"},{\"citys\":\"大庆\"},{\"citys\":\"哈尔滨\"},{\"citys\":\"齐齐哈尔\"},{\"citys\":\"牡丹江\"},{\"name\":\"辽宁\"},{\"citys\":\"沈阳\"},{\"citys\":\"大连\"},{\"citys\":\"盘锦\"},{\"name\":\"吉林\"},{\"citys\":\"吉林市\"},{\"citys\":\"长春\"},{\"citys\":\"四平\"}]}"; if(reader.parse(strValue,value))//解析出json放到json中区 { std::string out=value["name"].asString(); std::string out2=value["citys"].asString(); std::cout<<out<<std::endl; const Json::Value arrayObj=value["provinces"];//迭代器 for (int i=0; i < arrayObj.size();i++) { out=arrayObj[i]["name"].asString(); std::cout<<out; out=arrayObj[i]["citys"].asString(); std::cout<<out; if(i!=arrayObj.size()-1) std::cout<<std::endl;//; } } else std::cout<<"aaa"<<std::endl; } myfile.close(); getchar(); return 0; }

openvino里的object detection demo 运行的时候有很多报错是怎么回事?

代码如下:/* // Copyright (c) 2018 Intel Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. */ #include <gflags/gflags.h> #include <algorithm> #include <functional> #include <iostream> #include <fstream> #include <random> #include <string> #include <memory> #include <vector> #include <limits> #include <chrono> #include <format_reader_ptr.h> #include <inference_engine.hpp> #include <ext_list.hpp> #include <samples/common.hpp> #include <samples/slog.hpp> #include <samples/args_helper.hpp> #include "object_detection_demo.h" #include "detectionoutput.h" using namespace InferenceEngine; bool ParseAndCheckCommandLine(int argc, char *argv[]) { // ---------------------------Parsing and validation of input args-------------------------------------- slog::info << "Parsing input parameters" << slog::endl; gflags::ParseCommandLineNonHelpFlags(&argc, &argv, true); if (FLAGS_h) { showUsage(); return false; } if (FLAGS_ni < 1) { throw std::logic_error("Parameter -ni should be greater than 0 (default: 1)"); } if (FLAGS_i.empty()) { throw std::logic_error("Parameter -i is not set"); } if (FLAGS_m.empty()) { throw std::logic_error("Parameter -m is not set"); } return true; } /** * \brief The entry point for the Inference Engine object_detection demo application * \file object_detection_demo/main.cpp * \example object_detection_demo/main.cpp */ int main(int argc, char *argv[]) { try { /** This demo covers certain topology and cannot be generalized for any object detection one **/ slog::info << "InferenceEngine: " << GetInferenceEngineVersion() << "\n"; // ------------------------------ Parsing and validation of input args --------------------------------- if (!ParseAndCheckCommandLine(argc, argv)) { return 0; } /** This vector stores paths to the processed images **/ std::vector<std::string> images; parseImagesArguments(images); if (images.empty()) throw std::logic_error("No suitable images were found"); // ----------------------------------------------------------------------------------------------------- // --------------------------- 1. Load Plugin for inference engine ------------------------------------- slog::info << "Loading plugin" << slog::endl; InferencePlugin plugin = PluginDispatcher({ FLAGS_pp, "../../../lib/intel64" , "" }).getPluginByDevice(FLAGS_d); /*If CPU device, load default library with extensions that comes with the product*/ if (FLAGS_d.find("CPU") != std::string::npos) { /** * cpu_extensions library is compiled from "extension" folder containing * custom MKLDNNPlugin layer implementations. These layers are not supported * by mkldnn, but they can be useful for inferencing custom topologies. **/ plugin.AddExtension(std::make_shared<Extensions::Cpu::CpuExtensions>()); } if (!FLAGS_l.empty()) { // CPU(MKLDNN) extensions are loaded as a shared library and passed as a pointer to base extension IExtensionPtr extension_ptr = make_so_pointer<IExtension>(FLAGS_l); plugin.AddExtension(extension_ptr); slog::info << "CPU Extension loaded: " << FLAGS_l << slog::endl; } if (!FLAGS_c.empty()) { // clDNN Extensions are loaded from an .xml description and OpenCL kernel files plugin.SetConfig({ { PluginConfigParams::KEY_CONFIG_FILE, FLAGS_c } }); slog::info << "GPU Extension loaded: " << FLAGS_c << slog::endl; } /** Setting plugin parameter for per layer metrics **/ if (FLAGS_pc) { plugin.SetConfig({ { PluginConfigParams::KEY_PERF_COUNT, PluginConfigParams::YES } }); } /** Printing plugin version **/ printPluginVersion(plugin, std::cout); // ----------------------------------------------------------------------------------------------------- // --------------------------- 2. Read IR Generated by ModelOptimizer (.xml and .bin files) ------------ std::string binFileName = fileNameNoExt(FLAGS_m) + ".bin"; slog::info << "Loading network files:" "\n\t" << FLAGS_m << "\n\t" << binFileName << slog::endl; CNNNetReader networkReader; /** Read network model **/ networkReader.ReadNetwork(FLAGS_m); /** Extract model name and load weigts **/ networkReader.ReadWeights(binFileName); CNNNetwork network = networkReader.getNetwork(); Precision p = network.getPrecision(); // ----------------------------------------------------------------------------------------------------- // --------------------------- 3. Configure input & output --------------------------------------------- // ------------------------------ Adding DetectionOutput ----------------------------------------------- /** * The only meaningful difference between Faster-RCNN and SSD-like topologies is the interpretation * of the output data. Faster-RCNN has 2 output layers which (the same format) are presented inside SSD. * * But SSD has an additional post-processing DetectionOutput layer that simplifies output filtering. * So here we are adding 3 Reshapes and the DetectionOutput to the end of Faster-RCNN so it will return the * same result as SSD and we can easily parse it. */ std::string firstLayerName = network.getInputsInfo().begin()->first; int inputWidth = network.getInputsInfo().begin()->second->getTensorDesc().getDims()[3]; int inputHeight = network.getInputsInfo().begin()->second->getTensorDesc().getDims()[2]; DataPtr bbox_pred_reshapeInPort = ((ICNNNetwork&)network).getData(FLAGS_bbox_name.c_str()); if (bbox_pred_reshapeInPort == nullptr) { throw std::logic_error(std::string("Can't find output layer named ") + FLAGS_bbox_name); } SizeVector bbox_pred_reshapeOutDims = { bbox_pred_reshapeInPort->getTensorDesc().getDims()[0] * bbox_pred_reshapeInPort->getTensorDesc().getDims()[1], 1 }; DataPtr rois_reshapeInPort = ((ICNNNetwork&)network).getData(FLAGS_proposal_name.c_str()); if (rois_reshapeInPort == nullptr) { throw std::logic_error(std::string("Can't find output layer named ") + FLAGS_proposal_name); } SizeVector rois_reshapeOutDims = { rois_reshapeInPort->getTensorDesc().getDims()[0] * rois_reshapeInPort->getTensorDesc().getDims()[1], 1 }; DataPtr cls_prob_reshapeInPort = ((ICNNNetwork&)network).getData(FLAGS_prob_name.c_str()); if (cls_prob_reshapeInPort == nullptr) { throw std::logic_error(std::string("Can't find output layer named ") + FLAGS_prob_name); } SizeVector cls_prob_reshapeOutDims = { cls_prob_reshapeInPort->getTensorDesc().getDims()[0] * cls_prob_reshapeInPort->getTensorDesc().getDims()[1], 1 }; /* Detection output */ int normalized = 0; int prior_size = normalized ? 4 : 5; int num_priors = rois_reshapeOutDims[0] / prior_size; // num_classes guessed from the output dims if (bbox_pred_reshapeOutDims[0] % (num_priors * 4) != 0) { throw std::logic_error("Can't guess number of classes. Something's wrong with output layers dims"); } int num_classes = bbox_pred_reshapeOutDims[0] / (num_priors * 4); slog::info << "num_classes guessed: " << num_classes << slog::endl; LayerParams detectionOutParams; detectionOutParams.name = "detection_out"; detectionOutParams.type = "DetectionOutput"; detectionOutParams.precision = p; CNNLayerPtr detectionOutLayer = CNNLayerPtr(new CNNLayer(detectionOutParams)); detectionOutLayer->params["background_label_id"] = "0"; detectionOutLayer->params["code_type"] = "caffe.PriorBoxParameter.CENTER_SIZE"; detectionOutLayer->params["eta"] = "1.0"; detectionOutLayer->params["input_height"] = std::to_string(inputHeight); detectionOutLayer->params["input_width"] = std::to_string(inputWidth); detectionOutLayer->params["keep_top_k"] = "200"; detectionOutLayer->params["nms_threshold"] = "0.3"; detectionOutLayer->params["normalized"] = std::to_string(normalized); detectionOutLayer->params["num_classes"] = std::to_string(num_classes); detectionOutLayer->params["share_location"] = "0"; detectionOutLayer->params["top_k"] = "400"; detectionOutLayer->params["variance_encoded_in_target"] = "1"; detectionOutLayer->params["visualize"] = "False"; detectionOutLayer->insData.push_back(bbox_pred_reshapeInPort); detectionOutLayer->insData.push_back(cls_prob_reshapeInPort); detectionOutLayer->insData.push_back(rois_reshapeInPort); SizeVector detectionOutLayerOutDims = { 7, 200, 1, 1 }; DataPtr detectionOutLayerOutPort = DataPtr(new Data("detection_out", detectionOutLayerOutDims, p, TensorDesc::getLayoutByDims(detectionOutLayerOutDims))); detectionOutLayerOutPort->creatorLayer = detectionOutLayer; detectionOutLayer->outData.push_back(detectionOutLayerOutPort); DetectionOutputPostProcessor detOutPostProcessor(detectionOutLayer.get()); network.addOutput(FLAGS_bbox_name, 0); network.addOutput(FLAGS_prob_name, 0); network.addOutput(FLAGS_proposal_name, 0); // --------------------------- Prepare input blobs ----------------------------------------------------- slog::info << "Preparing input blobs" << slog::endl; /** Taking information about all topology inputs **/ InputsDataMap inputsInfo(network.getInputsInfo()); /** SSD network has one input and one output **/ if (inputsInfo.size() != 1 && inputsInfo.size() != 2) throw std::logic_error("Demo supports topologies only with 1 or 2 inputs"); std::string imageInputName, imInfoInputName; InputInfo::Ptr inputInfo = inputsInfo.begin()->second; SizeVector inputImageDims; /** Stores input image **/ /** Iterating over all input blobs **/ for (auto & item : inputsInfo) { /** Working with first input tensor that stores image **/ if (item.second->getInputData()->getTensorDesc().getDims().size() == 4) { imageInputName = item.first; slog::info << "Batch size is " << std::to_string(networkReader.getNetwork().getBatchSize()) << slog::endl; /** Creating first input blob **/ Precision inputPrecision = Precision::U8; item.second->setPrecision(inputPrecision); } else if (item.second->getInputData()->getTensorDesc().getDims().size() == 2) { imInfoInputName = item.first; Precision inputPrecision = Precision::FP32; item.second->setPrecision(inputPrecision); if ((item.second->getTensorDesc().getDims()[1] != 3 && item.second->getTensorDesc().getDims()[1] != 6) || item.second->getTensorDesc().getDims()[0] != 1) { throw std::logic_error("Invalid input info. Should be 3 or 6 values length"); } } } // ------------------------------ Prepare output blobs ------------------------------------------------- slog::info << "Preparing output blobs" << slog::endl; OutputsDataMap outputsInfo(network.getOutputsInfo()); const int maxProposalCount = detectionOutLayerOutDims[1]; const int objectSize = detectionOutLayerOutDims[0]; /** Set the precision of output data provided by the user, should be called before load of the network to the plugin **/ outputsInfo[FLAGS_bbox_name]->setPrecision(Precision::FP32); outputsInfo[FLAGS_prob_name]->setPrecision(Precision::FP32); outputsInfo[FLAGS_proposal_name]->setPrecision(Precision::FP32); // ----------------------------------------------------------------------------------------------------- // --------------------------- 4. Loading model to the plugin ------------------------------------------ slog::info << "Loading model to the plugin" << slog::endl; ExecutableNetwork executable_network = plugin.LoadNetwork(network, {}); // ----------------------------------------------------------------------------------------------------- // --------------------------- 5. Create infer request ------------------------------------------------- InferRequest infer_request = executable_network.CreateInferRequest(); // ----------------------------------------------------------------------------------------------------- // --------------------------- 6. Prepare input -------------------------------------------------------- /** Collect images data ptrs **/ std::vector<std::shared_ptr<unsigned char>> imagesData, originalImagesData; std::vector<int> imageWidths, imageHeights; for (auto & i : images) { FormatReader::ReaderPtr reader(i.c_str()); if (reader.get() == nullptr) { slog::warn << "Image " + i + " cannot be read!" << slog::endl; continue; } /** Store image data **/ std::shared_ptr<unsigned char> originalData(reader->getData()); std::shared_ptr<unsigned char> data(reader->getData(inputInfo->getTensorDesc().getDims()[3], inputInfo->getTensorDesc().getDims()[2])); if (data.get() != nullptr) { originalImagesData.push_back(originalData); imagesData.push_back(data); imageWidths.push_back(reader->width()); imageHeights.push_back(reader->height()); } } if (imagesData.empty()) throw std::logic_error("Valid input images were not found!"); size_t batchSize = network.getBatchSize(); slog::info << "Batch size is " << std::to_string(batchSize) << slog::endl; if (batchSize != imagesData.size()) { slog::warn << "Number of images " + std::to_string(imagesData.size()) + \ " doesn't match batch size " + std::to_string(batchSize) << slog::endl; slog::warn << std::to_string(std::min(imagesData.size(), batchSize)) + \ " images will be processed" << slog::endl; batchSize = std::min(batchSize, imagesData.size()); } /** Creating input blob **/ Blob::Ptr imageInput = infer_request.GetBlob(imageInputName); /** Filling input tensor with images. First b channel, then g and r channels **/ size_t num_channels = imageInput->getTensorDesc().getDims()[1]; size_t image_size = imageInput->getTensorDesc().getDims()[3] * imageInput->getTensorDesc().getDims()[2]; unsigned char* data = static_cast<unsigned char*>(imageInput->buffer()); /** Iterate over all input images **/ for (size_t image_id = 0; image_id < std::min(imagesData.size(), batchSize); ++image_id) { /** Iterate over all pixel in image (b,g,r) **/ for (size_t pid = 0; pid < image_size; pid++) { /** Iterate over all channels **/ for (size_t ch = 0; ch < num_channels; ++ch) { /** [images stride + channels stride + pixel id ] all in bytes **/ data[image_id * image_size * num_channels + ch * image_size + pid] = imagesData.at(image_id).get()[pid*num_channels + ch]; } } } if (imInfoInputName != "") { Blob::Ptr input2 = infer_request.GetBlob(imInfoInputName); auto imInfoDim = inputsInfo.find(imInfoInputName)->second->getTensorDesc().getDims()[1]; /** Fill input tensor with values **/ float *p = input2->buffer().as<PrecisionTrait<Precision::FP32>::value_type*>(); for (size_t image_id = 0; image_id < std::min(imagesData.size(), batchSize); ++image_id) { p[image_id * imInfoDim + 0] = static_cast<float>(inputsInfo[imageInputName]->getTensorDesc().getDims()[2]); p[image_id * imInfoDim + 1] = static_cast<float>(inputsInfo[imageInputName]->getTensorDesc().getDims()[3]); for (int k = 2; k < imInfoDim; k++) { p[image_id * imInfoDim + k] = 1.0f; // all scale factors are set to 1.0 } } } // ----------------------------------------------------------------------------------------------------- // ---------------------------- 7. Do inference -------------------------------------------------------- slog::info << "Start inference (" << FLAGS_ni << " iterations)" << slog::endl; typedef std::chrono::high_resolution_clock Time; typedef std::chrono::duration<double, std::ratio<1, 1000>> ms; typedef std::chrono::duration<float> fsec; double total = 0.0; /** Start inference & calc performance **/ for (int iter = 0; iter < FLAGS_ni; ++iter) { auto t0 = Time::now(); infer_request.Infer(); auto t1 = Time::now(); fsec fs = t1 - t0; ms d = std::chrono::duration_cast<ms>(fs); total += d.count(); } // ----------------------------------------------------------------------------------------------------- // ---------------------------- 8. Process output ------------------------------------------------------ slog::info << "Processing output blobs" << slog::endl; Blob::Ptr bbox_output_blob = infer_request.GetBlob(FLAGS_bbox_name); Blob::Ptr prob_output_blob = infer_request.GetBlob(FLAGS_prob_name); Blob::Ptr rois_output_blob = infer_request.GetBlob(FLAGS_proposal_name); std::vector<Blob::Ptr> detOutInBlobs = { bbox_output_blob, prob_output_blob, rois_output_blob }; Blob::Ptr output_blob = std::make_shared<TBlob<float>>(Precision::FP32, Layout::NCHW, detectionOutLayerOutDims); output_blob->allocate(); std::vector<Blob::Ptr> detOutOutBlobs = { output_blob }; detOutPostProcessor.execute(detOutInBlobs, detOutOutBlobs, nullptr); const float* detection = static_cast<PrecisionTrait<Precision::FP32>::value_type*>(output_blob->buffer()); std::vector<std::vector<int> > boxes(batchSize); std::vector<std::vector<int> > classes(batchSize); /* Each detection has image_id that denotes processed image */ for (int curProposal = 0; curProposal < maxProposalCount; curProposal++) { float image_id = detection[curProposal * objectSize + 0]; float label = detection[curProposal * objectSize + 1]; float confidence = detection[curProposal * objectSize + 2]; float xmin = detection[curProposal * objectSize + 3] * imageWidths[image_id]; float ymin = detection[curProposal * objectSize + 4] * imageHeights[image_id]; float xmax = detection[curProposal * objectSize + 5] * imageWidths[image_id]; float ymax = detection[curProposal * objectSize + 6] * imageHeights[image_id]; /* MKLDnn and clDNN have little differente in DetectionOutput layer, so we need this check */ if (image_id < 0 || confidence == 0) { continue; } std::cout << "[" << curProposal << "," << label << "] element, prob = " << confidence << " (" << xmin << "," << ymin << ")-(" << xmax << "," << ymax << ")" << " batch id : " << image_id; if (confidence > 0.5) { /** Drawing only objects with >50% probability **/ classes[image_id].push_back(static_cast<int>(label)); boxes[image_id].push_back(static_cast<int>(xmin)); boxes[image_id].push_back(static_cast<int>(ymin)); boxes[image_id].push_back(static_cast<int>(xmax - xmin)); boxes[image_id].push_back(static_cast<int>(ymax - ymin)); std::cout << " WILL BE PRINTED!"; } std::cout << std::endl; } for (size_t batch_id = 0; batch_id < batchSize; ++batch_id) { addRectangles(originalImagesData[batch_id].get(), imageHeights[batch_id], imageWidths[batch_id], boxes[batch_id], classes[batch_id]); const std::string image_path = "out_" + std::to_string(batch_id) + ".bmp"; if (writeOutputBmp(image_path, originalImagesData[batch_id].get(), imageHeights[batch_id], imageWidths[batch_id])) { slog::info << "Image " + image_path + " created!" << slog::endl; } else { throw std::logic_error(std::string("Can't create a file: ") + image_path); } } // ----------------------------------------------------------------------------------------------------- std::cout << std::endl << "total inference time: " << total << std::endl; std::cout << "Average running time of one iteration: " << total / static_cast<double>(FLAGS_ni) << " ms" << std::endl; std::cout << std::endl << "Throughput: " << 1000 * static_cast<double>(FLAGS_ni) * batchSize / total << " FPS" << std::endl; std::cout << std::endl; /** Show performace results **/ if (FLAGS_pc) { printPerformanceCounts(infer_request, std::cout); } } catch (const std::exception& error) { slog::err << error.what() << slog::endl; return 1; } catch (...) { slog::err << "Unknown/internal exception happened." << slog::endl; return 1; } slog::info << "Execution successful" << slog::endl; return 0; } 有如下报错:严重性 代码 说明 项目 文件 行 禁止显示状态 错误 LNK2019 无法解析的外部符号 CreateFormatReader,该符号在函数 "public: __cdecl FormatReader::ReaderPtr::ReaderPtr(char const *)" (??0ReaderPtr@FormatReader@@QEAA@PEBD@Z) 中被引用 88999 c:\Users\颜俊毅\documents\visual studio 2015\Projects\88999\88999\7521.obj 1 错误(活动) 无法引用 函数 "InferenceEngine::make_so_pointer<T>(const std::string &name) [其中 T=InferenceEngine::IExtension]" (已声明 所在行数:164,所属文件:"c:\Users\颜俊毅\Desktop\dldt-2018\inference-engine\include\details\ie_so_pointer.hpp") -- 它是已删除的函数 88999 c:\Users\颜俊毅\Documents\Visual Studio 2015\Projects\88999\88999\7521.cpp 102 错误 LNK2019 无法解析的外部符号 __imp_CreateDefaultAllocator,该符号在函数 "protected: virtual class std::shared_ptr<class InferenceEngine::IAllocator> const & __cdecl InferenceEngine::TBlob<int,struct std::enable_if<1,void> >::getAllocator(void)const " (?getAllocator@?$TBlob@HU?$enable_if@$00X@std@@@InferenceEngine@@MEBAAEBV?$shared_ptr@VIAllocator@InferenceEngine@@@std@@XZ) 中被引用 88999 c:\Users\颜俊毅\documents\visual studio 2015\Projects\88999\88999\7521.obj 1 错误 LNK2019 无法解析的外部符号 "__declspec(dllimport) public: __cdecl InferenceEngine::BlockingDesc::BlockingDesc(class std::vector<unsigned __int64,class std::allocator<unsigned __int64> > const &,class std::vector<unsigned __int64,class std::allocator<unsigned __int64> > const &)" (__imp_??0BlockingDesc@InferenceEngine@@QEAA@AEBV?$vector@_KV?$allocator@_K@std@@@std@@0@Z),该符号在函数 "public: __cdecl DetectionOutputPostProcessor::DetectionOutputPostProcessor(class InferenceEngine::CNNLayer const *)" (??0DetectionOutputPostProcessor@@QEAA@PEBVCNNLayer@InferenceEngine@@@Z) 中被引用 88999 c:\Users\颜俊毅\documents\visual studio 2015\Projects\88999\88999\7521.obj 1 错误 LNK2019 无法解析的外部符号 "__declspec(dllimport) public: virtual __cdecl InferenceEngine::BlockingDesc::~BlockingDesc(void)" (__imp_??1BlockingDesc@InferenceEngine@@UEAA@XZ),该符号在函数 "public: __cdecl DetectionOutputPostProcessor::DetectionOutputPostProcessor(class InferenceEngine::CNNLayer const *)" (??0DetectionOutputPostProcessor@@QEAA@PEBVCNNLayer@InferenceEngine@@@Z) 中被引用 88999 c:\Users\颜俊毅\documents\visual studio 2015\Projects\88999\88999\7521.obj 1 错误 LNK2019 无法解析的外部符号 "__declspec(dllimport) public: __cdecl InferenceEngine::TensorDesc::TensorDesc(class InferenceEngine::Precision const &,class std::vector<unsigned __int64,class std::allocator<unsigned __int64> >,class InferenceEngine::BlockingDesc const &)" (__imp_??0TensorDesc@InferenceEngine@@QEAA@AEBVPrecision@1@V?$vector@_KV?$allocator@_K@std@@@std@@AEBVBlockingDesc@1@@Z),该符号在函数 "public: __cdecl DetectionOutputPostProcessor::DetectionOutputPostProcessor(class InferenceEngine::CNNLayer const *)" (??0DetectionOutputPostProcessor@@QEAA@PEBVCNNLayer@InferenceEngine@@@Z) 中被引用 88999 c:\Users\颜俊毅\documents\visual studio 2015\Projects\88999\88999\7521.obj 1 错误 LNK2019 无法解析的外部符号 "__declspec(dllimport) public: __cdecl InferenceEngine::TensorDesc::TensorDesc(class InferenceEngine::Precision const &,class std::vector<unsigned __int64,class std::allocator<unsigned __int64> >,enum InferenceEngine::Layout)" (__imp_??0TensorDesc@InferenceEngine@@QEAA@AEBVPrecision@1@V?$vector@_KV?$allocator@_K@std@@@std@@W4Layout@1@@Z),该符号在函数 "public: __cdecl InferenceEngine::Blob::Blob(class InferenceEngine::Precision,enum InferenceEngine::Layout,class std::vector<unsigned __int64,class std::allocator<unsigned __int64> > const &)" (??0Blob@InferenceEngine@@QEAA@VPrecision@1@W4Layout@1@AEBV?$vector@_KV?$allocator@_K@std@@@std@@@Z) 中被引用 88999 c:\Users\颜俊毅\documents\visual studio 2015\Projects\88999\88999\7521.obj 1 错误 LNK2019 无法解析的外部符号 "__declspec(dllimport) public: virtual __cdecl InferenceEngine::TensorDesc::~TensorDesc(void)" (__imp_??1TensorDesc@InferenceEngine@@UEAA@XZ),该符号在函数 "public: __cdecl InferenceEngine::Blob::Blob(class InferenceEngine::TensorDesc)" (??0Blob@InferenceEngine@@QEAA@VTensorDesc@1@@Z) 中被引用 88999 c:\Users\颜俊毅\documents\visual studio 2015\Projects\88999\88999\7521.obj 1 错误 LNK2019 无法解析的外部符号 "__declspec(dllimport) public: class std::vector<unsigned __int64,class std::allocator<unsigned __int64> > & __cdecl InferenceEngine::TensorDesc::getDims(void)" (__imp_?getDims@TensorDesc@InferenceEngine@@QEAAAEAV?$vector@_KV?$allocator@_K@std@@@std@@XZ),该符号在函数 "public: virtual void __cdecl InferenceEngine::TBlob<int,struct std::enable_if<1,void> >::allocate(void)" (?allocate@?$TBlob@HU?$enable_if@$00X@std@@@InferenceEngine@@UEAAXXZ) 中被引用 88999 c:\Users\颜俊毅\documents\visual studio 2015\Projects\88999\88999\7521.obj 1 错误 LNK2019 无法解析的外部符号 "__declspec(dllimport) public: class std::vector<unsigned __int64,class std::allocator<unsigned __int64> > const & __cdecl InferenceEngine::TensorDesc::getDims(void)const " (__imp_?getDims@TensorDesc@InferenceEngine@@QEBAAEBV?$vector@_KV?$allocator@_K@std@@@std@@XZ),该符号在函数 "public: unsigned __int64 __cdecl InferenceEngine::Blob::byteSize(void)const " (?byteSize@Blob@InferenceEngine@@QEBA_KXZ) 中被引用 88999 c:\Users\颜俊毅\documents\visual studio 2015\Projects\88999\88999\7521.obj 1 错误 LNK2019 无法解析的外部符号 "__declspec(dllimport) public: static enum InferenceEngine::Layout __cdecl InferenceEngine::TensorDesc::getLayoutByDims(class std::vector<unsigned __int64,class std::allocator<unsigned __int64> >)" (__imp_?getLayoutByDims@TensorDesc@InferenceEngine@@SA?AW4Layout@2@V?$vector@_KV?$allocator@_K@std@@@std@@@Z),该符号在函数 main 中被引用 88999 c:\Users\颜俊毅\documents\visual studio 2015\Projects\88999\88999\7521.obj 1 错误 LNK2019 无法解析的外部符号 "__declspec(dllimport) public: __cdecl InferenceEngine::TensorDesc::TensorDesc(class InferenceEngine::TensorDesc const &)" (__imp_??0TensorDesc@InferenceEngine@@QEAA@AEBV01@@Z),该符号在函数 "public: __cdecl InferenceEngine::TBlob<int,struct std::enable_if<1,void> >::TBlob<int,struct std::enable_if<1,void> >(class InferenceEngine::TensorDesc const &)" (??0?$TBlob@HU?$enable_if@$00X@std@@@InferenceEngine@@QEAA@AEBVTensorDesc@1@@Z) 中被引用 88999 c:\Users\颜俊毅\documents\visual studio 2015\Projects\88999\88999\7521.obj 1 错误 LNK2019 无法解析的外部符号 "__declspec(dllimport) public: __cdecl InferenceEngine::Data::Data(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::vector<unsigned __int64,class std::allocator<unsigned __int64> > const &,class InferenceEngine::Precision,enum InferenceEngine::Layout)" (__imp_??0Data@InferenceEngine@@QEAA@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEBV?$vector@_KV?$allocator@_K@std@@@3@VPrecision@1@W4Layout@1@@Z),该符号在函数 main 中被引用 88999 c:\Users\颜俊毅\documents\visual studio 2015\Projects\88999\88999\7521.obj 1 错误 LNK2019 无法解析的外部符号 "__declspec(dllimport) public: class InferenceEngine::TensorDesc const & __cdecl InferenceEngine::Data::getTensorDesc(void)const " (__imp_?getTensorDesc@Data@InferenceEngine@@QEBAAEBVTensorDesc@2@XZ),该符号在函数 "public: virtual class std::map<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::vector<unsigned __int64,class std::allocator<unsigned __int64> >,struct std::less<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,class std::vector<unsigned __int64,class std::allocator<unsigned __int64> > > > > __cdecl InferenceEngine::CNNNetwork::getInputShapes(void)" (?getInputShapes@CNNNetwork@InferenceEngine@@UEAA?AV?$map@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$vector@_KV?$allocator@_K@std@@@2@U?$less@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$vector@_KV?$allocator@_K@std@@@2@@std@@@2@@std@@XZ) 中被引用 88999 c:\Users\颜俊毅\documents\visual studio 2015\Projects\88999\88999\7521.obj 1 错误 LNK2019 无法解析的外部符号 "__declspec(dllimport) public: void __cdecl InferenceEngine::Data::setPrecision(class InferenceEngine::Precision const &)" (__imp_?setPrecision@Data@InferenceEngine@@QEAAXAEBVPrecision@2@@Z),该符号在函数 "public: void __cdecl InferenceEngine::InputInfo::setPrecision(class InferenceEngine::Precision)" (?setPrecision@InputInfo@InferenceEngine@@QEAAXVPrecision@2@@Z) 中被引用 88999 c:\Users\颜俊毅\documents\visual studio 2015\Projects\88999\88999\7521.obj 1 错误 LNK2019 无法解析的外部符号 "__declspec(dllimport) public: __cdecl InferenceEngine::Data::~Data(void)" (__imp_??1Data@InferenceEngine@@QEAA@XZ),该符号在函数 "public: void * __cdecl InferenceEngine::Data::`scalar deleting destructor'(unsigned int)" (??_GData@InferenceEngine@@QEAAPEAXI@Z) 中被引用 88999 c:\Users\颜俊毅\documents\visual studio 2015\Projects\88999\88999\7521.obj 1 错误 LNK2019 无法解析的外部符号 __imp_findPlugin,该符号在函数 "public: class InferenceEngine::details::SOPointer<class InferenceEngine::IInferencePlugin,class InferenceEngine::details::SharedObjectLoader> __cdecl InferenceEngine::PluginDispatcher::getSuitablePlugin(enum InferenceEngine::TargetDevice)const " (?getSuitablePlugin@PluginDispatcher@InferenceEngine@@QEBA?AV?$SOPointer@VIInferencePlugin@InferenceEngine@@VSharedObjectLoader@details@2@@details@2@W4TargetDevice@2@@Z) 中被引用 88999 c:\Users\颜俊毅\documents\visual studio 2015\Projects\88999\88999\7521.obj 1 错误 LNK2019 无法解析的外部符号 __imp_GetInferenceEngineVersion,该符号在函数 main 中被引用 88999 c:\Users\颜俊毅\documents\visual studio 2015\Projects\88999\88999\7521.obj 1 错误 LNK2019 无法解析的外部符号 __imp_CreateCNNNetReader,该符号在函数 "public: __cdecl InferenceEngine::CNNNetReader::CNNNetReader(void)" (??0CNNNetReader@InferenceEngine@@QEAA@XZ) 中被引用 88999 c:\Users\颜俊毅\documents\visual studio 2015\Projects\88999\88999\7521.obj 1 错误 LNK2019 无法解析的外部符号 "__declspec(dllimport) public: __cdecl InferenceEngine::Extensions::Cpu::CpuExtensions::CpuExtensions(void)" (__imp_??0CpuExtensions@Cpu@Extensions@InferenceEngine@@QEAA@XZ),该符号在函数 "public: __cdecl std::_Ref_count_obj<class InferenceEngine::Extensions::Cpu::CpuExtensions>::_Ref_count_obj<class InferenceEngine::Extensions::Cpu::CpuExtensions><>(void)" (??$?0$$V@?$_Ref_count_obj@VCpuExtensions@Cpu@Extensions@InferenceEngine@@@std@@QEAA@XZ) 中被引用 88999 c:\Users\颜俊毅\documents\visual studio 2015\Projects\88999\88999\7521.obj 1 错误 LNK2019 无法解析的外部符号 "__declspec(dllimport) public: virtual __cdecl InferenceEngine::Extensions::Cpu::CpuExtensions::~CpuExtensions(void)" (__imp_??1CpuExtensions@Cpu@Extensions@InferenceEngine@@UEAA@XZ),该符号在函数 "public: virtual void * __cdecl InferenceEngine::Extensions::Cpu::CpuExtensions::`scalar deleting destructor'(unsigned int)" (??_GCpuExtensions@Cpu@Extensions@InferenceEngine@@UEAAPEAXI@Z) 中被引用 88999 c:\Users\颜俊毅\documents\visual studio 2015\Projects\88999\88999\7521.obj 1 错误 LNK2001 无法解析的外部符号 "public: virtual void __cdecl InferenceEngine::Extensions::Cpu::CpuExtensions::GetVersion(struct InferenceEngine::Version const * &)const " (?GetVersion@CpuExtensions@Cpu@Extensions@InferenceEngine@@UEBAXAEAPEBUVersion@4@@Z) 88999 c:\Users\颜俊毅\documents\visual studio 2015\Projects\88999\88999\7521.obj 1 错误 LNK2001 无法解析的外部符号 "public: virtual void __cdecl InferenceEngine::Extensions::Cpu::CpuExtensions::Release(void)" (?Release@CpuExtensions@Cpu@Extensions@InferenceEngine@@UEAAXXZ) 88999 c:\Users\颜俊毅\documents\visual studio 2015\Projects\88999\88999\7521.obj 1 错误 LNK2001 无法解析的外部符号 "public: virtual void __cdecl InferenceEngine::Extensions::Cpu::CpuExtensions::SetLogCallback(class InferenceEngine::IErrorListener &)" (?SetLogCallback@CpuExtensions@Cpu@Extensions@InferenceEngine@@UEAAXAEAVIErrorListener@4@@Z) 88999 c:\Users\颜俊毅\documents\visual studio 2015\Projects\88999\88999\7521.obj 1 错误 LNK2001 无法解析的外部符号 "public: virtual void __cdecl InferenceEngine::Extensions::Cpu::CpuExtensions::Unload(void)" (?Unload@CpuExtensions@Cpu@Extensions@InferenceEngine@@UEAAXXZ) 88999 c:\Users\颜俊毅\documents\visual studio 2015\Projects\88999\88999\7521.obj 1 错误 LNK2001 无法解析的外部符号 "public: virtual enum InferenceEngine::StatusCode __cdecl InferenceEngine::Extensions::Cpu::CpuExtensions::getFactoryFor(class InferenceEngine::ILayerImplFactory * &,class InferenceEngine::CNNLayer const *,struct InferenceEngine::ResponseDesc *)" (?getFactoryFor@CpuExtensions@Cpu@Extensions@InferenceEngine@@UEAA?AW4StatusCode@4@AEAPEAVILayerImplFactory@4@PEBVCNNLayer@4@PEAUResponseDesc@4@@Z) 88999 c:\Users\颜俊毅\documents\visual studio 2015\Projects\88999\88999\7521.obj 1 错误 LNK2001 无法解析的外部符号 "public: virtual enum InferenceEngine::StatusCode __cdecl InferenceEngine::Extensions::Cpu::CpuExtensions::getPrimitiveTypes(char * * &,unsigned int &,struct InferenceEngine::ResponseDesc *)" (?getPrimitiveTypes@CpuExtensions@Cpu@Extensions@InferenceEngine@@UEAA?AW4StatusCode@4@AEAPEAPEADAEAIPEAUResponseDesc@4@@Z) 88999 c:\Users\颜俊毅\documents\visual studio 2015\Projects\88999\88999\7521.obj 1 错误 LNK2001 无法解析的外部符号 "public: virtual enum InferenceEngine::StatusCode __cdecl InferenceEngine::Extensions::Cpu::CpuExtensions::getShapeInferImpl(class std::shared_ptr<class InferenceEngine::IShapeInferImpl> &,char const *,struct InferenceEngine::ResponseDesc *)" (?getShapeInferImpl@CpuExtensions@Cpu@Extensions@InferenceEngine@@UEAA?AW4StatusCode@4@AEAV?$shared_ptr@VIShapeInferImpl@InferenceEngine@@@std@@PEBDPEAUResponseDesc@4@@Z) 88999 c:\Users\颜俊毅\documents\visual studio 2015\Projects\88999\88999\7521.obj 1 错误 LNK1120 27 个无法解析的外部命令 88999 c:\users\颜俊毅\documents\visual studio 2015\Projects\88999\x64\Debug\88999.exe 1

C++为什么将含有string类型的数据成员的类对象转换为char*类型会出错?

把string改成char就没问题 头文件 ``` #pragma once #include<string> using namespace std; class Extest { public : Extest(); void show(); void input(); private: int a; int b; string c;//char c[20]={'\0'}; }; ``` cpp文件 ``` #include<iostream> #include<fstream> using namespace std; #include "extest.h" int main() { Extest obj1; obj1.input(); Extest obj2; ofstream out("Object.txt", ios_base::out | ios_base::trunc | ios_base::binary); if (!out.is_open()) cout << "FAIL" << endl; out.write((const char*)&obj1, sizeof(Extest)); out.close(); ifstream in("Object.txt", ios_base::in | ios_base::binary); if (!in.is_open()) cout << "FAIL" << endl; while (in.peek() != EOF) { in.read((char*)&obj2, sizeof(Extest)); } in.close(); obj2.show(); return 0; } Extest::Extest() { a = 0; b = 0; c = "NO";//for(int i=0;i<20;i++)c[i]={'\0'}; } void Extest::show() { cout <<"a:"<< a << endl; cout << "b:" << b << endl; cout << "c:" << c << endl; } void Extest::input() { cin >> a >> b; cin>> c; } ``` ![图片说明](https://img-ask.csdn.net/upload/202006/13/1592035613_876938.png) 请各路大神解答!

C++ openssl aes加密失败

我在使用openssl的aes(cbc)加密字节超过96的字符串后,在解密就会少字符,下面是我写的代码,求大神指点下什么问题,AES一次加密的明文是有长度限制么? CooloiAES::CooloiAES() : MSG_LEN(0) { for(int i = 0; i < AES_BLOCK_SIZE; i++) { key[i] = 32 + i; } } CooloiAES::~CooloiAES() { } std::string CooloiAES::aes_encrypt(std::string msg) { int i = msg.size() / 16; MSG_LEN = ( i + 1 ) * 16; //MSG_LEN = msg.size() + 16; char in[MSG_LEN]; char out[MSG_LEN]; memset((char*)in,0,MSG_LEN); memset((char*)out,0,MSG_LEN); //strncpy((char*)in,msg.c_str(),msg.size()); //memcpy((char*)in,msg.data(),msg.size()); strcpy((char*)in,msg.c_str()); unsigned char iv[AES_BLOCK_SIZE]; //加密的初始化向量 for(int j = 0; j < AES_BLOCK_SIZE; ++j) { iv[j] = 0; } AES_KEY aes; if(AES_set_encrypt_key((unsigned char*)key, 128, &aes) < 0) { return NULL; } size_t len = strlen(in); std::cout << "LEN ::::: " << len << std::endl; AES_cbc_encrypt((unsigned char*)in,(unsigned char*)out,len,&aes,iv,AES_ENCRYPT); std::string encrypt_msg(&out[0],&out[MSG_LEN+16]); for(int i= 0;out[i];i++){ printf("%x",(unsigned char)out[i]); //std::cout << dstStringTemp[i]; } std::cout << std::endl; return encrypt_msg; } std::string CooloiAES::aes_decrypt(std::string msg) { MSG_LEN = msg.size(); char in[MSG_LEN]; char out[MSG_LEN+16]; memset((char*)in,0,MSG_LEN); memset((char*)out,0,MSG_LEN+16); //strncpy((char*)in,msg.c_str(),msg.size()); memcpy((char*)in,msg.data(),msg.size()); for(int i= 0;in[i];i++){ printf("%x",(unsigned char)in[i]); //std::cout << dstStringTemp[i]; } std::cout << std::endl; unsigned char iv[AES_BLOCK_SIZE]; //加密的初始化向量 for(int j = 0; j < AES_BLOCK_SIZE; ++j) { iv[j] = 0; } AES_KEY aes; if(AES_set_decrypt_key((unsigned char*)key, 128, &aes) < 0) { return NULL; } //int len = msg.size(); size_t len = strlen(in); AES_cbc_encrypt((unsigned char*)in,(unsigned char*)out,len,&aes,iv,AES_DECRYPT); std::string decrypt_msg = out; return decrypt_msg; } ``` ```

C++模板函数,传参数后参数添加了const属性

成员模板函数,传入非const参数,在函数中得到const属性。怎么能让传入后属性不变啊?现象如下: ``` /// a.h class A{ public: template<typename DataType> static bool GetData(DataType *out){ std::cout << typeid(out).name() << std::endl; return true; } }; ///main.cpp struct Point2D{ float x; float y; }; int main(int argc, char *argv[]) { Point2D p2d2{1.0, 2.0}; std::cout << typeid(&p2d2).name() << std::endl; std::thread t([=](){ BlackBoard::GetData( &p2d2); }); t.join(); return 0; } /// output /* 传入前输出:struct Point2D * __ptr64 传入后输出:struct Point2D const * __ptr64 */ ``` 求大神指点

一个C++链表问题........

写完了一半我觉得C++真是一门神秘的语言,我小看它了。。。求大佬帮助,写了个鬼的链表它死活就是连不上,代码如下。ps:大家可以不用看其他的函数,重点看看链接链表的函数,它只要能连上其他的不是什么问题。。 ``` #include <iostream> #include <fstream> #include <string> #include <stdlib.h> #pragma warning(disable:4996) using namespace std; class Class { private: std::string c_id; std::string c_name; std::string nature; std::string total_time; std::string xuefen; std::string nos; //选修该课程学生的人数 char **S; public: Class(); Class(std::string, std::string, std::string ,std::string, std::string, std::string); friend class Student; friend class Manage; Class *me; Class *next; void set(std::string, std::string, std::string, std::string, std::string, std::string); void add_c(Class &,Class &); void search1(std::string); void display(Class); void display_ALL(); void edit(std::string); void del(std::string); void count(); void count_s(); void save(); void load(); }; class Manage { public: Student *s1; Class *c1; Manage(); void choose_c(); }; class Student { private: std::string s_id; std::string name; char sex; int age; std::string xi; std::string class1; std::string tel; char **C; public: Manage m; Class *p; Student *me; Student *next; Student(); Student(std::string, std::string, char, int, std::string, std::string, std::string, char *); friend class Manage; void add_s(Student); void search(std::string); void display(); void display_ALL(); void edit(std::string); void del(std::string); void count(); void save(); void load(); }; //class Manage //{ //public: // Student *s1; // Class *c1; // Manage(); // void choose_c(); //}; Class::Class() { int i; this->me =this; this->next = NULL; this->S = new char*[5]; for (i = 0; i < 5; i++) { *(S + i) = new char[50]; *(S + i) = NULL; } } Class::Class(std::string s, std::string s1,std::string c, std::string a, std::string b, std::string c1) { int i = 0; this->c_id = s; this->c_name = s1; this->nature = c; this->total_time = a; this->xuefen = b; this->nos = c1; this->S = new char*[5]; for (i = 0; i < 5; i++) { *(S + i) = new char[50]; *(S + i) = NULL; } me = this; this->next = NULL; } void Class::set(std::string s, std::string s1, std::string s2, std::string s3, std::string s4, std::string s5) { this->c_id = s; this->c_name = s1; this->nature = s2; this->total_time = s3; this->xuefen = s4; this->nos = s5; } void Class::add_c(Class &c,Class &c1) { c.next = this->next; this->next = c.me; } void Class::search1(std::string s) { int i = 0; Class *p; p = this->me; while (p != NULL) { if (p->c_name == s) { std::cout << p->c_id << endl; std::cout << p->c_name << endl; std::cout << p->nature << endl; cout << p->total_time << endl; cout << p->xuefen << endl; cout << p->nos << endl; if (p->S == NULL) cout << "还未选课,无选课信息." << endl; else { for (i = 0; i < 5; i++) cout << p->S[i] << endl; } break; } else p = p->next; } if (p == NULL) cout << "未找到指定信息" << endl; } void Class::display(Class c) { int i = 0; cout << c.c_id << endl; cout << c.c_name << endl; cout << c.nature << endl; cout << c.total_time << endl; cout << c.xuefen << endl; cout << c.nos << endl; if (c.S == NULL) cout << "还未选课,无选课信息." << endl; else { for (i = 0; i < 5; i++) cout << c.S[i] << endl; } } void Class::display_ALL() { int i = 0; Class *p; p = this; if (p == NULL) cout << "表中无信息" << endl; while (p != NULL) { cout << p->c_id << endl; cout << p->c_name << endl; cout << p->nature << endl; cout << p->total_time << endl; cout << p->xuefen << endl; cout << p->nos << endl; if (p->S == NULL) cout << "还未选课,无选课信息." << endl; else { for (i = 0; i < 5; i++) cout << p->S[i] << endl; } i = 0; p = p->next; } } void Class::edit(std::string s) { Class *p; p = this; while (p != NULL) { if (p->c_name == s) { cout << "请输入想要修改的学号:" << endl; cin >> p->c_id; } else p = p->next; } if (p == NULL) cout << "未找到修改位置." << endl; } void Class::del(std::string s) { Class *p,*p1; p = this; while (p != NULL) { if (p->next->c_name == s) { p1 = p->next; p->next = p->next->next; delete p1; break; } else p = p->next; } if (p == NULL) cout << "未找到想删除的元素." << endl; } void Class::count() { int count = 0; Class *p; p = this; while (p != NULL) count++; cout << "一共" << count << "门课程" << endl; } void Class::save() { //char *p1; Class *p; int i; p = this; ofstream ofile("E:\\Student_data.txt",ios::out); if (ofile.good()) cout << "文件已被成功打开!" << endl; else exit(0); //p1 = p->S[0]; i = 0; while (p != NULL) { ofile << p->c_id; ofile << "\n"; ofile << p->c_name; ofile << "\n"; ofile << p->nature; ofile << "\n"; ofile << p->total_time; ofile << "\n"; ofile << p->xuefen; ofile << "\n"; while (1) { if (i == 5) break; if (p->S[i] != NULL) { ofile << p->S[i]; ofile << "\n"; i++; } else { ofile << "\n"; i++; } } p = p->next; } } void Class::load() { string ch; int i ; char *temp; temp = new char[20]; Class *p; p = this; ifstream ifile("E:\\Student_data.txt", ios::out); getline(ifile, ch); p->c_id = ch; getline(ifile, ch); p->c_name = ch; getline(ifile, ch); p->nature = ch; getline(ifile, ch); p->total_time = ch; getline(ifile, ch); p->xuefen = ch; getline(ifile, ch); p->nos = ch; int j; for (i = 0; i < 5; i++) { getline(ifile, ch); if (ch.size() < 2) { for (j = 0; j < ch.size(); j++) temp[j] = ch[j]; temp[j] = '\0'; strcpy(p->S[i], temp); } else { p->S[i] = NULL; } } while (1) { p = new Class; getline(ifile,ch); if (ch.size()<2) break; p->c_id = ch; getline(ifile, ch); p->c_name = ch; getline(ifile, ch); p->nature = ch; getline(ifile, ch); p->total_time = ch; getline(ifile, ch); p->xuefen = ch; getline(ifile, ch); p->nos = ch; for (i = 0; i < 5; i++) { getline(ifile, ch); if (ch.size() < 2) { for (j = 0; j < ch.size(); j++) temp[j] = ch[j]; temp[j] = '\0'; strcpy(p->S[i], temp); } else { p->S[i] = NULL; } } p->next = this->next; this->next = p; } } void main() { string s, s1, s2, s3, s4, s5; Class C,*p; int i,n; cout << "请输入数目:"; cin >> n; cout << "请输入一系列:"; cin >> s>>s1>>s2>>s3>>s4>>s5; C.set(s,s1,s2,s3,s4,s5); for (i = 0; i < n - 1; i++) { cout << "请输入一系列:"; cin >> s >> s1 >> s2 >> s3 >> s4 >> s5; Class C1(s,s1,s2,s3,s4,s5); C.add_c(C,C1); } cout << "请输入搜索的名字:"; cin >> s; C.search1(s); cout << "显示第一项:"; C.display(C); cout << "显示所有项"; C.display_ALL(); cout << "输入待编辑的人员姓名"; cin >> s; C.edit(s); C.display_ALL(); cout << "请输入要删除的项:"; cin >> s; C.del(s); C.display_ALL(); cout << "显示课程数目:"; C.count(); cout << "开始保存"; C.save(); } ```

C++代码运行中出现无法解析的外部命令?

代码的作用是定义一个点类Point,派生出圆类和圆柱体类Circle和Cylinder 功能是输出圆的周长(通过定义的Cirfer()函数)、面积(定义有Area()函数)和圆柱体的表面积和体积 ![图片说明](https://img-ask.csdn.net/upload/201910/13/1570977934_645492.jpg) ``` //Shape.h #ifndef SHAPE_H #define SHAPE_H #include<iostream> #define PI 3.1415926 using namespace std; class Point { public: Point(double X, double Y); //构造函数 void Set(double X, double Y); //设置点值 double Getx()const; //获取横坐标 double Gety()const; //获取纵坐标 virtual void Output(ostream &out) const; //输出函数 virtual void Input(istream &in); //输入函数 protected: double x, y; }; class Circle :public Point { public: Circle(const Point &p, double R); void Set(double X, double Y, double R); void Set(const Point &p, double R); double Getr()const; double Area(); //计算圆的面积 double Cirfer(); //计算圆的周长 void Output(ostream &out)const; void Input(istream &in); protected: double r; }; class Cylinder :public Circle { public: Cylinder(const Circle& c, double H); void Set(const Circle& c, double H); double Geth()const; double Area(); //计算圆柱体的表面积 double Volume(); //计算圆柱体体积 void Output(ostream& out)const; void Input(istream& in); protected: double h; }; ostream& operator<<(ostream& out, const Point& p); //输出运算符重载 istream& operator>>(istream& in, const Point& p); //输入运算符重载 #endif //Shape.cpp #include<iostream> #include"Shape.h" using namespace std; ostream & operator<<(ostream &out, const Point &p) //输出运算符重载 { p.Output(out); return out; } istream & operator>>(istream &in, Point &p) //输入运算符重载 { p.Input(in); return in; } //Point类成员函数 Point::Point(double X, double Y) :x(X), y(Y) {} void Point::Set(double X, double Y) { x = X, y = Y; } double Point::Getx()const { return x; } double Point::Gety()const { return y; } void Point::Output(ostream &out)const { out << '(' << x << "," << y << ')'; } void Point::Input(istream& in) { char str[80]; in.getline(str, 80, '('); in.getline(str, 80, ','); x = atof(str); //atof()是字符从ASCII转为float型数据 in.getline(str, 80, ')'); y = atof(str); } //Circle类成员函数 Circle::Circle(const Point& p, double R) : Point(p), r(R) {} void Circle::Set(double X, double Y, double R) { x = X, y = Y, r = R; } void Circle::Set(const Point& p, double R) { Point::Set(p.Getx(), p.Gety()); r = R; } double Circle::Getr()const { return r; } double Circle::Area() //圆面积 { return PI * r * r; } double Circle::Cirfer() //圆周长 { return 2 * PI * r; } void Circle::Output(ostream& out)const { out << '[' << '(' << x << "," << y << ')' << "," << r << ']'; } void Circle::Input(istream& in) { char str[80]; in.getline(str, 80, '['); Point::Input(in); in.getline(str, 80, ','); in.getline(str, 80, ']'); r = atof(str); } //Cylinder类成员函数 Cylinder::Cylinder(const Circle& c, double H) :Circle(c), h(H) {} void Cylinder::Set(const Circle& c, double H) { Circle::Set(Getx(),Gety(),Getr()); h = H; } double Cylinder::Geth()const { return h; } double Cylinder::Area() //圆柱体表面积 { return PI*r*r* 2+2*PI*r*h; } double Cylinder::Volume() //圆柱体体积 { return PI*r*r* h; } void Cylinder::Output(ostream& out)const { out << '{'; Circle::Output(out); out << "," << h << '}'; } void Cylinder::Input(istream& in) { char str[80]; in.getline(str, 80, '{'); Circle::Input(in); in.getline(str, 80, ','); in.getline(str, 80, '}'); h = atof(str); } //test.cpp #include<iostream> #include"Shape.h" int main() { Point p(5, 8); //初始化各个类的数据成员 Circle c(p, 10); Cylinder y(c, 8); cout << c << "\tArea:" << c.Area() << "\t\tCircumference" << c.Cirfer() << '\n' << y << "\tArea:" << y.Area() << "\tVolume:" << y.Volume() << endl; cout << "\n请注意键盘输入格式。"; cout << "\n包括圆括号、方括号、花括号、逗号,"; cout << "其中可以插入或不插入空格、<Tab>、换行。" << endl; cout << "请输入一个点 (x, y) : "; cin >> p; cout << "结果:" << p << endl; cout << "请输入一个圆 [(x, y), r] : "; cin >> c; cout << "结果:" << c << endl; cout << "请输入一个圆柱 {[(x, y), r], h} : "; cin >> y; cout << "结果:" << y << endl; return 0; } ```

vector out of range如何预防

做了个小软件,在做异常处理,正确格式是形如“CIK2+2.22”这样的,CI可以没有,但是每次我的输入是“K+”的时候,他就会弹出vector out of range的错误弹框,试了网上很多解决的代码还是没有用,想找大佬帮着看看。 附上代码: #include <iostream> #include <string> #include <boost/algorithm/string.hpp> #include<vector> #include<sstream> #include <cmath> #include <iomanip> using namespace std; class Mileage { public: int p; double q; string c; string mileage; Mileage(string); double getkm(void) { return p + 0.001*q; } double getm(void) { return 1000 * p + q; } double inckm(double i) { double j; double sum; j = getkm(); sum = i + j; return sum; } private: string a; string b; }; Mileage::Mileage(string ss) { mileage = ss; vector<string>num; boost::split(num, mileage, boost::is_any_of("K+"), boost::token_compress_on); a = num[1]; b = num[2]; c = num[0]; stringstream aa(a.c_str()); aa >> p; stringstream bb(b.c_str()); bb >> q; } double getdist(double m, double n) { return n - m; } bool checkNum(string str) { unsigned int iSize = str.size(); unsigned int i = 0; int icount = 0; int iCount = 0; for (i = 0; i <= iSize; i++) { if ('K' == str[i]) { icount++; } else if ('+' == str[i]) { iCount++; } } if (icount != 1 || iCount != 1) { cout << "Wrong! The format of chainage number is not correct. "; return true; } else return false; } bool compare(string m, string n) { vector<string>v; vector<string>w; boost::split(v, m, boost::is_any_of("K+"), boost::token_compress_on); boost::split(w, n, boost::is_any_of("K+"), boost::token_compress_on); string sa = v[0]; string sb = w[0]; if (v[0] == w[0]) return false; else { cout << "The crown number is not same!"; return true; } } bool checkTh(string ss) { vector<string>v; boost::split(v, ss, boost::is_any_of("K+"), boost::token_compress_on); string d = v[2]; double ddd; stringstream dd(d.c_str()); dd >> ddd; if (ddd >= 1000) { cout << "Wrong Chainage Number B!"; return true; } else return false; } int main() { cout << "Please enter the chainage number: "; string m; string M; cin >> m; while (checkNum(m)||checkTh(m)) { cout << "Please enter the correct number:"; cin >> m; }M = m; Mileage x(M); double g = x.getkm(); char ch; cout << "The function of this program is: " << endl; cout << "A. Unified the unit of chainage number to km." << endl; cout << "B. Unified the unit of chainage number to m." << endl; cout << "C. correct the chainage number." << endl; cout << "D. calculate the distance." << endl; cout << "Please choose your demand: "; cin >> ch; switch (ch) { case 'A': cout << "The chainage number is: " << x.getkm() << endl; break; case 'B': cout << "The chainage number is: " << x.getm() << endl; break; case 'C': { double cor; cout << "Please enter the correct number: "; cin >> cor; double corl; corl = x.inckm(cor); while (corl < 0) { cout << "Too many subtraction,the result is out of range!" << endl; cout << "Please enter the correct number again: "; cin >> cor; corl = x.inckm(cor); } int kilometer; double meter; kilometer = (int)corl; meter = (corl - kilometer) * 1000; cout << "The corrected chainage number is: " << x.c << "K" << kilometer << "+" ; cout << fixed << setprecision(3) << meter << endl break; } case 'D': cout << "Please enter another chainage number: "; string n; string N; cin >> n; while (checkNum(n)||compare(M,n) || checkTh(n)) { cout << "Please enter the correct number:"; cin >> n; }N = n; Mileage y(N); double h = y.getkm(); double dist; dist = getdist(g, h); cout << "The distance between them is: " << dist << "km" << endl; break; } system("pause"); return 0; }

用c++读取文件内容时遇到的问题,跪求解答~~

#include <iostream> #include <string> #include "sale.h" using namespace std; int main() { int iFlag=1; //循环是否结束的标志 int iOrder; string account,password; // char *account,*password;//定义账号密码 cout<<"*******1.管理员登录*******"<<endl; cout<<"*******2.销售经理登录*****"<<endl; cout<<"*******3.销售员登录*******"<<endl; cout<<"Please input the order:"; cin>>iOrder; switch(iOrder){ //管理员的操作 case 1:{ while(iFlag){ string saleMagAcnt,saleMagPswd; Manager manager; cout<<"Please input the account:"<<endl; cin>>account; cout<<"Please input the password:"<<endl; cin>>password; if(account.compare(manager.getAccount())==0&&password.compare(manager.getPassword())==0){ int nFlag=1; while(nFlag){ //int nOrder=0; manager.printOrder(); cout<<"Please input the order:"; cin>>iOrder; switch(iOrder){ case 1:{ manager.setSaleManagerAccount(); //设置销售经理账号 } break; //break 放到里边和外边的区别 case 2:{ manager.setSaleManAccount( ); //设置销售员账号 } break; case 3:{ manager.deleteAccont(); //删除帐号信息 } break; case 4:{manager.print(); } break; case 5:{ manager.printOrder(); //打印指令 } break; case 6:{ manager.initial(); //初始化 } break; case 0:{ nFlag=0; //退出系统 } break; } } iFlag=0; } else { cout<<"account or password wrong! Please input again!"<<endl; //缺少一个可以循环输入的while循环 } } } break; //销售经理的操作 case 2:{ } break; //销售员的操作 case 3:{ } break; } return 0; } #ifndef SALE_H_INCLUDED #define SALE_H_INCLUDED #include <string> using namespace std; struct saleData{ //销售物品的结构体 int number; char saleName[40]; long balance; double price; }; struct salesAccont{ //销售账户结构体 string account,password; }; //空标志记录 class Manager{ //管理员类 private: string account, password; //¹ÜÀíÔ±Õ˺ÅÃÜÂë string saleMagAcnt,saleMagPwd; public: Manager(); string getAccount(); string getPassword(); void printOrder(); //打印指令 void setSaleManagerAccount();//设置销售经理账号 void setSaleManAccount( );//设置销售员账号 void deleteAccont(); //删除账户 void changeMsg(); void initial(); //初始化文件 int print(); int endMark(salesAccont sl); }; class SalesManager{ //销售经理类 }; class SalesMan{ //销售员类 }; #endif // SALE_H_INCLUDED #include <iostream> #include "sale.h" #include <fstream> salesAccont mark={"NULL","NULL"}; Manager::Manager(){ account="manager01"; password="gk2001"; } string Manager::getAccount(){ return account; } string Manager::getPassword(){ return password; } //打印指令 void Manager::printOrder(){ cout<<"*****1.创建销售经理用户*****"<<endl; cout<<"*****2.创建销售员用户*******"<<endl; cout<<"*****3.删除用户信息*********"<<endl; cout<<"*****4.修改用户信息*********"<<endl; cout<<"*****5.重新显示指令*********"<<endl; cout<<"*****6.初始化文件***********"<<endl; cout<<"*****0.退出销售系统*********"<<endl; } //设置销售经理账号 void Manager::setSaleManagerAccount(){ salesAccont sl; fstream slMngr("../saleSystem/salesaccount.dat",ios::out|ios::binary); //只能有out,否则打开文件失败 if(!slMngr){ cout<<"文件打开失败!"<<endl; return; } //slMngr.seekg(0,ios::beg);//将指针移到文件头 /*do{ slMngr.read((char*)&sl,sizeof(salesAccont)); }while(!endMark(sl)); slMngr.seekp(-long(sizeof(salesAccont)),ios::cur);*/ while(true){ cout<<"请输入销售经理账号:"; cin>>sl.account; cout<<"请输入密码:"; cin>>sl.password; if(sl.account=="NULL"|| sl.account=="null") break; slMngr.write((char*)&sl,sizeof(salesAccont)); //加入账号= } slMngr.close(); } //设置销售员账号 void Manager::setSaleManAccount(){ salesAccont sl; fstream slMn; slMn.open("../saleSystem/salesaccount.dat",ios::out|ios::binary); if(!slMn){ cout<<"文件打开失败!"<<endl; return; } // slMn.seekg(0,ios::beg);//将指针移到文件头 /* do{ slMngr.read((char*)&sl,sizeof(salesMangerAcnt)); }while(!endMark(sl));*/ cout<<"请输入销售员账号:"; cin>>sl.account; cout<<"请输入密码:"; cin>>sl.password; slMn.write((char*)&sl,sizeof(salesAccont)); //加入账号= slMn.write((char*)&mark,sizeof(salesAccont)); slMn.close(); } //删除成员信息 void Manager::deleteAccont(){ string key; cout<<"please input the account you want to delete:"; cin>>key; salesAccont sl; fstream f1("../saleSystem/salesaccount.dat",ios::in|ios::out|ios::binary); f1.seekg(0,ios::beg); do{ f1.read((char*)&sl,sizeof(salesAccont)); if(sl.account!=key) f1.write("../saleSystem/salesaccount1.dat",sizeof(salesAccont)); }while(endMark(sl)); if(sl.account!=key) cout<<"没有此帐号"<<endl; f1.close(); } //初始化文件 void Manager::initial(){ fstream fdat("../saleSystem/salesaccount.dat",ios::out|ios::binary); cout<<"若文件存在,还需要初始化吗?(Y/N):"; char answer; cin>>answer; if(answer=='Y'||answer=='y'){ fdat.seekg(0,ios::beg); fdat.write((char*)&mark,sizeof(salesAccont)); cout<<"文件已经初始化。"<<endl; } else cout<<"取消操作"<<endl; fdat.close(); } /*istream_iterator<string>ii(f1); istream_iterator<string> eos; vector<string>b (ii,eos); //将文件的内容存入容器中 vector<string>::iterator it; //使用迭代器 for(it = b.begin() ; it<b.end();it++) { if(key == *it) { *it = ""; //如果找到要删除的内容,将对应的迭代器内容清空 } } ofstream wr(f1,ios::out); for(it=b.begin() ; it<b.end();it++) //重新写回文件 { wr << *it <<endl; cout << *it<< endl; } }*/ //打印出文件的内容 测试文件的输出 int Manager::print(){ salesAccont sl; fstream f1("../saleSystem/salesaccount.dat",ios::in|ios::binary); if(f1.eof()){ cout<<"文件打开失败!"; return 0; } /* f1.seekg(0,ios::beg);//将指针移到文件头 // int i=0; do{ f1.read((char *)&sl,sizeof(salesAccont)); if(endMark(sl)) cout<<sl.account<<endl; // i++; }while(endMark(sl));//while(i<3);*/ while(true){ f1.read((char*)&sl,sizeof(salesAccont)); if(f1.eof()) break; cout<<sl.account<<endl; } f1.close(); } int Manager::endMark(salesAccont sl){ //判断是否读到文件末尾 if(sl.account!="NULL") return 1; return 0; } void Manager::changeMsg(){ string key; cout<<"please input the account you want to delete:"; cin>>key; salesAccont sl; fstream f1("../saleSystem/salesaccount.dat",ios::in|ios::out|ios::binary); /* f1.seekg(0,ios::beg); do{ f1.read((char*)&sl,sizeof(salesAccont)); if(sl.account==key){ cout<<"请输入修改后的账号:"; cin>>sl.account; cout<<"请输入修改后的密码:"; cin>>sl.password; f1.write("../saleSystem/salesaccount1.dat",sizeof(salesAccont)); } }while(endMark(sl));*/ }

Python可以这样学(第一季:Python内功修炼)

董付国系列教材《Python程序设计基础》、《Python程序设计(第2版)》、《Python可以这样学》配套视频,讲解Python 3.5.x和3.6.x语法、内置对象用法、选择与循环以及函数设计与使用、lambda表达式用法、字符串与正则表达式应用、面向对象编程、文本文件与二进制文件操作、目录操作与系统运维、异常处理结构。

获取Linux下Ftp目录树并逐步绑定到treeview

在linux下抓取目录树,双击后获取该节点子节点(逐步生成)。另外有两个类,一个是windows下的(一次性获取目录树),一个是linux下的(足部获取目录树)

NS网络模拟和协议仿真源代码

NS网络模拟和协议仿真源代码,包含代码说明及协议分析

简单的NS3网络模拟仿真(计算机网络作业)

简单的NS3网络模拟仿真,内附有PPT演示。论文评述。以及简单的安装教程。

手把手实现Java图书管理系统(附源码)

【超实用课程内容】 本课程演示的是一套基于Java的SSM框架实现的图书管理系统,主要针对计算机相关专业的正在做毕设的学生与需要项目实战练习的java人群。详细介绍了图书管理系统的实现,包括:环境搭建、系统业务、技术实现、项目运行、功能演示、系统扩展等,以通俗易懂的方式,手把手的带你从零开始运行本套图书管理系统,该项目附带全部源码可作为毕设使用。 【课程如何观看?】 PC端:https://edu.csdn.net/course/detail/27513 移动端:CSDN 学院APP(注意不是CSDN APP哦) 本课程为录播课,课程2年有效观看时长,大家可以抓紧时间学习后一起讨论哦~ 【学员专享增值服务】 源码开放 课件、课程案例代码完全开放给你,你可以根据所学知识,自行修改、优化

三个项目玩转深度学习(附1G源码)

从事大数据与人工智能开发与实践约十年,钱老师亲自见证了大数据行业的发展与人工智能的从冷到热。事实证明,计算机技术的发展,算力突破,海量数据,机器人技术等,开启了第四次工业革命的序章。深度学习图像分类一直是人工智能的经典任务,是智慧零售、安防、无人驾驶等机器视觉应用领域的核心技术之一,掌握图像分类技术是机器视觉学习的重中之重。针对现有线上学习的特点与实际需求,我们开发了人工智能案例实战系列课程。打造:以项目案例实践为驱动的课程学习方式,覆盖了智能零售,智慧交通等常见领域,通过基础学习、项目案例实践、社群答疑,三维立体的方式,打造最好的学习效果。

150讲轻松搞定Python网络爬虫

【为什么学爬虫?】 &nbsp; &nbsp; &nbsp; &nbsp;1、爬虫入手容易,但是深入较难,如何写出高效率的爬虫,如何写出灵活性高可扩展的爬虫都是一项技术活。另外在爬虫过程中,经常容易遇到被反爬虫,比如字体反爬、IP识别、验证码等,如何层层攻克难点拿到想要的数据,这门课程,你都能学到! &nbsp; &nbsp; &nbsp; &nbsp;2、如果是作为一个其他行业的开发者,比如app开发,web开发,学习爬虫能让你加强对技术的认知,能够开发出更加安全的软件和网站 【课程设计】 一个完整的爬虫程序,无论大小,总体来说可以分成三个步骤,分别是: 网络请求:模拟浏览器的行为从网上抓取数据。 数据解析:将请求下来的数据进行过滤,提取我们想要的数据。 数据存储:将提取到的数据存储到硬盘或者内存中。比如用mysql数据库或者redis等。 那么本课程也是按照这几个步骤循序渐进的进行讲解,带领学生完整的掌握每个步骤的技术。另外,因为爬虫的多样性,在爬取的过程中可能会发生被反爬、效率低下等。因此我们又增加了两个章节用来提高爬虫程序的灵活性,分别是: 爬虫进阶:包括IP代理,多线程爬虫,图形验证码识别、JS加密解密、动态网页爬虫、字体反爬识别等。 Scrapy和分布式爬虫:Scrapy框架、Scrapy-redis组件、分布式爬虫等。 通过爬虫进阶的知识点我们能应付大量的反爬网站,而Scrapy框架作为一个专业的爬虫框架,使用他可以快速提高我们编写爬虫程序的效率和速度。另外如果一台机器不能满足你的需求,我们可以用分布式爬虫让多台机器帮助你快速爬取数据。 &nbsp; 从基础爬虫到商业化应用爬虫,本套课程满足您的所有需求! 【课程服务】 专属付费社群+每周三讨论会+1v1答疑

cuda开发cutilDLL

包括cutil32.dll、cutil32D.dll、cutil32.lib、cutil32D.lib,以及附带的glew32.lib/freeglut.lib

深度学习原理+项目实战+算法详解+主流框架(套餐)

深度学习系列课程从深度学习基础知识点开始讲解一步步进入神经网络的世界再到卷积和递归神经网络,详解各大经典网络架构。实战部分选择当下最火爆深度学习框架PyTorch与Tensorflow/Keras,全程实战演示框架核心使用与建模方法。项目实战部分选择计算机视觉与自然语言处理领域经典项目,从零开始详解算法原理,debug模式逐行代码解读。适合准备就业和转行的同学们加入学习! 建议按照下列课程顺序来进行学习 (1)掌握深度学习必备经典网络架构 (2)深度框架实战方法 (3)计算机视觉与自然语言处理项目实战。(按照课程排列顺序即可)

Tensorflow与python3.7适配版本

tensorflow与python3.7匹配的最新库,更新了python3.7以后可以自行下载,或者去国外python的扩展包下载界面自行下载。

4小时玩转微信小程序——基础入门与微信支付实战

这是一个门针对零基础学员学习微信小程序开发的视频教学课程。课程采用腾讯官方文档作为教程的唯一技术资料来源。杜绝网络上质量良莠不齐的资料给学员学习带来的障碍。 视频课程按照开发工具的下载、安装、使用、程序结构、视图层、逻辑层、微信小程序等几个部分组织课程,详细讲解整个小程序的开发过程

专为程序员设计的数学课

<p> 限时福利限时福利,<span>15000+程序员的选择!</span> </p> <p> 购课后添加学习助手(微信号:csdn590),按提示消息领取编程大礼包!并获取讲师答疑服务! </p> <p> <br> </p> <p> 套餐中一共包含5门程序员必学的数学课程(共47讲) </p> <p> 课程1:《零基础入门微积分》 </p> <p> 课程2:《数理统计与概率论》 </p> <p> 课程3:《代码学习线性代数》 </p> <p> 课程4:《数据处理的最优化》 </p> <p> 课程5:《马尔可夫随机过程》 </p> <p> <br> </p> <p> 哪些人适合学习这门课程? </p> <p> 1)大学生,平时只学习了数学理论,并未接触如何应用数学解决编程问题; </p> <p> 2)对算法、数据结构掌握程度薄弱的人,数学可以让你更好的理解算法、数据结构原理及应用; </p> <p> 3)看不懂大牛代码设计思想的人,因为所有的程序设计底层逻辑都是数学; </p> <p> 4)想学习新技术,如:人工智能、机器学习、深度学习等,这门课程是你的必修课程; </p> <p> 5)想修炼更好的编程内功,在遇到问题时可以灵活的应用数学思维解决问题。 </p> <p> <br> </p> <p> 在这门「专为程序员设计的数学课」系列课中,我们保证你能收获到这些:<br> <br> <span> </span> </p> <p class="ql-long-24357476"> <span class="ql-author-24357476">①价值300元编程课程大礼包</span> </p> <p class="ql-long-24357476"> <span class="ql-author-24357476">②应用数学优化代码的实操方法</span> </p> <p class="ql-long-24357476"> <span class="ql-author-24357476">③数学理论在编程实战中的应用</span> </p> <p class="ql-long-24357476"> <span class="ql-author-24357476">④程序员必学的5大数学知识</span> </p> <p class="ql-long-24357476"> <span class="ql-author-24357476">⑤人工智能领域必修数学课</span> </p> <p> <br> 备注:此课程只讲程序员所需要的数学,即使你数学基础薄弱,也能听懂,只需要初中的数学知识就足矣。<br> <br> 如何听课? </p> <p> 1、登录CSDN学院 APP 在我的课程中进行学习; </p> <p> 2、登录CSDN学院官网。 </p> <p> <br> </p> <p> 购课后如何领取免费赠送的编程大礼包和加入答疑群? </p> <p> 购课后,添加助教微信:<span> csdn590</span>,按提示领取编程大礼包,或观看付费视频的第一节内容扫码进群答疑交流! </p> <p> <img src="https://img-bss.csdn.net/201912251155398753.jpg" alt=""> </p>

实现简单的文件系统

实验内容: 通过对具体的文件存储空间的管理、文件的物理结构、目录结构和文件操作的实现,加深对文件系统内部功能和实现过程的理解。 要求: 1.在内存中开辟一个虚拟磁盘空间作为文件存储器,在其上实现一个简

机器学习初学者必会的案例精讲

通过六个实际的编码项目,带领同学入门人工智能。这些项目涉及机器学习(回归,分类,聚类),深度学习(神经网络),底层数学算法,Weka数据挖掘,利用Git开源项目实战等。

四分之一悬架模型simulink.7z

首先建立了四分之一车辆悬架系统的数学模型,应用MATLAB/Simulink软件建立该系统的仿真模型,并输入路面激励为随机激励,控制不同的悬架刚度和阻尼,选用最优的参数得到车辆悬架的振动加速度变化曲线

MFC一站式终极全套课程包

该套餐共包含从C小白到C++到MFC的全部课程,整套学下来绝对成为一名C++大牛!!!

C++语言基础视频教程

C++语言基础视频培训课程:本课与主讲者在大学开出的程序设计课程直接对接,准确把握知识点,注重教学视频与实践体系的结合,帮助初学者有效学习。本教程详细介绍C++语言中的封装、数据隐藏、继承、多态的实现等入门知识;主要包括类的声明、对象定义、构造函数和析构函数、运算符重载、继承和派生、多态性实现等。 课程需要有C语言程序设计的基础(可以利用本人开出的《C语言与程序设计》系列课学习)。学习者能够通过实践的方式,学会利用C++语言解决问题,具备进一步学习利用C++开发应用程序的基础。

Java8零基础入门视频教程

这门课程基于主流的java8平台,由浅入深的详细讲解了java SE的开发技术,可以使java方向的入门学员,快速扎实的掌握java开发技术!

HoloLens2开发入门教程

本课程为HoloLens2开发入门教程,讲解部署开发环境,安装VS2019,Unity版本,Windows SDK,创建Unity项目,讲解如何使用MRTK,编辑器模拟手势交互,打包VS工程并编译部署应用到HoloLens上等。

C/C++学习指南全套教程

C/C++学习的全套教程,从基本语法,基本原理,到界面开发、网络开发、Linux开发、安全算法,应用尽用。由毕业于清华大学的业内人士执课,为C/C++编程爱好者的教程。

pokemmo的资源

pokemmo必须的4个rom 分别为绿宝石 火红 心金 黑白 还有汉化补丁 资源不错哦 记得下载

test_head.py

本文件主要是针对使用dlib的imglab标注工具标记的目标检测框和关键点检测而生成的xml文件, 转换为coco数据集格式.

Java面试史上最全的JAVA专业术语面试100问 (前1-50)

前言: 说在前面, 面试题是根据一些朋友去面试提供的,再就是从网上整理了一些。 先更新50道,下一波吧后面的也更出来。 求赞求关注!! 废话也不多说,现在就来看看有哪些面试题 1、面向对象的特点有哪些? 抽象、继承、封装、多态。 2、接口和抽象类有什么联系和区别? 3、重载和重写有什么区别? 4、java有哪些基本数据类型? 5、数组有没有length()方法?String有没有length()方法? 数组没有length()方法,它有length属性。 String有length()方法。 集合求长度用

2019 AI开发者大会

2019 AI开发者大会(AI ProCon 2019)是由中国IT社区CSDN主办的AI技术与产业年度盛会。多年经验淬炼,如今蓄势待发:2019年9月6-7日,大会将有近百位中美顶尖AI专家、知名企业代表以及千余名AI开发者齐聚北京,进行技术解读和产业论证。我们不空谈口号,只谈技术,诚挚邀请AI业内人士一起共铸人工智能新篇章!

linux“开发工具三剑客”速成攻略

工欲善其事,必先利其器。Vim+Git+Makefile是Linux环境下嵌入式开发常用的工具。本专题主要面向初次接触Linux的新手,熟练掌握工作中常用的工具,在以后的学习和工作中提高效率。

DirectX修复工具V4.0增强版

DirectX修复工具(DirectX Repair)是一款系统级工具软件,简便易用。本程序为绿色版,无需安装,可直接运行。 本程序的主要功能是检测当前系统的DirectX状态,如果发现异常则进行修复

20行代码教你用python给证件照换底色

20行代码教你用python给证件照换底色

2019 Python开发者日-培训

本次活动将秉承“只讲技术,拒绝空谈”的理念,邀请十余位身处一线的Python技术专家,重点围绕Web开发、自动化运维、数据分析、人工智能等技术模块,分享真实生产环境中使用Python应对IT挑战的真知灼见。此外,针对不同层次的开发者,大会还安排了深度培训实操环节,为开发者们带来更多深度实战的机会。

我以为我对Mysql事务很熟,直到我遇到了阿里面试官

太惨了,面试又被吊打

相关热词 c#框体中的退出函数 c# 按钮透明背景 c# idl 混编出错 c#在位置0处没有任何行 c# 循环给数组插入数据 c# 多线程死锁的例子 c# 钉钉读取员工排班 c# label 不显示 c#裁剪影像 c#工作进程更新ui
立即提问