C++中string::type_size到底是什么,该如何理解

在学习C++过程中写了如下一串代码,调试过程中只有输入英文字母才会结束程序(跳出循环),按照我的理解只要输入的参数n不是string::size _ type就能跳出while循环了啊。
#include
using namespace std;
int main() {

  const string hexdigits = "0123456789ABCDEFF";
  cout << "please enter a series of number between 0 and 15\n"
    << "Separated by spaces. Hit Enter when finished: "
    << endl;
string result;
  string::size_type n;
  while (cin >> n)
       if (n < hexdigits.size())
            result += hexdigits[n];
   cout << "your hex number is " << result << endl;
   return 0;

}
kenny06
kenny06 { const string hexdigits = "0123456789ABCDEF"; cout << "0 and 15 " << endl; string result; string::size_type n; while (cin >> n) if (n >= hexdigits.size()) break; else { result += hexdigits[n]; } cout << result << endl; return 0; }
8 个月之前 回复
kenny06
kenny06 我改了一下,从0输到16就会结束,参考一下,新手
8 个月之前 回复
kenny06
kenny06 { const string hexdigits = "0123456789ABCDEF"; cout << "0 and 15 " << endl; string result; string::size_type n; while (cin >> n) if (n >= hexdigits.size()) break; else { result += hexdigits[n]; } cout << result << endl; return 0; }
8 个月之前 回复

4个回答

你的理解基本是对的,除了英文字母外,输入#、¥、%、^等 非数字字符 也会结束循环。

string::size_type是STL库模板类string的一个成员变量,这部分内容要深入学习可能耗时太多。
简单的讲,它相当于int类型,区别在于它的大小范围要比int类型大得多。

可以参考:

https://msdn.microsoft.com/library/a9c3e0a2-39bf-4c8a-b093-9abe30839591.aspx#basic_string__size_type

如果对您有帮助,请采纳答案好吗,谢谢!

fight_in_dl
战在春秋 补充一下,代码没有问题,可以跑出循环。
2 年多之前 回复

你连 break 都没有 咋跳出循环? 你这个就是个死循环,会一直写到result的后面。

cin>>n 当循环条件的话,返回值是一个cin对象,即返回一个输入流, 输入流的结束,可以是报错和EOF:
报错可以用非法的输入,类型不匹配,a,b,c,d,输入大小超过最大值,

键盘模拟EOF windows 用ctrl+c 模拟,linux 可以用 ctrl+d,这样都可以结束本次循环。

string::size_type就是string类内部定义的一个类型别名,就typedef出来的一个类型,用来表示字符串长度的非负整形。
具体是什么类型不重要......

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
C++中string::type_size到底是什么,该如何理解
在学习C++过程中写了如下一串代码,调试过程中只有输入英文字母才会结束程序(跳出循环),按照我的理解只要输入的参数n不是string::size _ type就能跳出while循环了啊。 #include<string> using namespace std; int main() { const string hexdigits = "0123456789ABCDEFF"; cout << "please enter a series of number between 0 and 15\n" << "Separated by spaces. Hit Enter when finished: " << endl; string result; string::size_type n; while (cin >> n) if (n < hexdigits.size()) result += hexdigits[n]; cout << "your hex number is " << result << endl; return 0; }
不能将参数 1 从“char”转换为“const std::basic_string<_Elem,_Traits,_Ax> &” 如何解决?
代码如下 在utility文件下报错: error C2664: “std::basic_string<_Elem,_Traits,_Ax>::basic_string(const std::basic_string<_Elem,_Traits,_Ax> &)”: 不能将参数 1 从“char”转换为“const std::basic_string<_Elem,_Traits,_Ax> &” int _tmain(int argc, _TCHAR* argv[]) { ifstream ifs_str("F:/title.txt"); ofstream ofs_str("F:/out_title.txt"); hash_map<const int,vector<string>>map_1; vector<string>vec_1; hash_map<string,set<int>>map_2; set<int>set_2; vector<string>vec_2; string str_line; while(getline(ifs_str,str_line)){ istringstream is_str(str_line); int k; string v; is_str>>k; is_str>>v; vec_1.push_back(v); map_1.insert(hash_map<int,vector<string>>::value_type(k,vec_1)); } int i, j; for (i = 0; i <vec_1.size() ; i++) { for(j = 0;j < vec_1.size() ; j++) if (!map_1.count(vec_1[i][j])){ for(hash_map<const int,vector<string>>::iterator it =map_1.begin(); it!= map_1.end();++it) set_2.insert(it->first); } map_2.insert(hash_map<string,set<int>>::value_type(vec_1[i][j],set_2)); } for(hash_map<string,set<int>>::iterator it_1 =map_2.begin(); it_1 != map_2.end(); ++it_1){ ofs_str<<it_1->first<<"\t"; for(set<int>::iterator it_set = it_1->second.begin(); it_set != it_1->second.end(); ++it_set) ofs_str<<*it_set<<"\t"; ofs_str<<endl; } ifs_str.close(); ofs_str.close(); }
这样的coredump如何定位问题,求大神指导
# 一个服务程序,平均一天挂一次,coredump内容都已一样,分析不出来 ``` c++ Program terminated with signal 11, Segmentation fault. #0 SLL_Next (t=0x2) at src/linked_list.h:45 45 src/linked_list.h: No such file or directory. Missing separate debuginfos, use: debuginfo-install glibc-2.17-260.el7.x86_64 keyutils-libs-1.5.8-3.el7.x86_64 krb5-libs-1.15.1-34.el7.x86_64 libcom_err-1.42.9-13.el7.x86_64 libgcc-4.8.5-36.el7.x86_64 libselinux-2.5-14.1.el7.x86_64 libstdc++-4.8.5-36.el7.x86_64 nspr-4.19.0-1.el7_5.x86_64 nss-3.36.0-7.el7_5.x86_64 openldap-2.4.44-20.el7.x86_64 pcre-8.32-17.el7.x86_64 zlib-1.2.7-18.el7.x86_64 (gdb) bt #0 SLL_Next (t=0x2) at src/linked_list.h:45 #1 SLL_TryPop (rv=<synthetic pointer>, list=0x1f9c080) at src/linked_list.h:69 #2 TryPop (rv=<synthetic pointer>, this=0x1f9c080) at src/thread_cache.h:220 #3 Allocate (cl=4, size=48, this=<optimized out>) at src/thread_cache.h:381 #4 malloc_fast_path<tcmalloc::allocate_full_cpp_throw_oom> (size=<optimized out>) at src/tcmalloc.cc:1751 #5 tc_new (size=<optimized out>) at src/tcmalloc.cc:1851 #6 0x00007fd6bf3bca19 in std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&) () from /lib64/libstdc++.so.6 #7 0x00007fd6c2c3842d in char* std::string::_S_construct<char const*>(char const*, char const*, std::allocator<char> const&, std::forward_iterator_tag) () from ./lib/libcpprest.so.2.10 #8 0x00007fd6bf3be6d8 in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) () from /lib64/libstdc++.so.6 #9 0x000000000069b836 in InformationCommand::Process (this=0x7ec8a38, task=..., response=@0x7fd58890f3f8: 0x0) at src/modules/DataCommand/InformationCommand.cpp:74 #10 0x0000000000724c62 in ThreadPoolGateway::task (this=0x252bda0, task=0x3b792f0) at src/modules/Servers/impl/ThreadPoolGateway.cpp:115 #11 0x0000000000726306 in boost::_mfi::mf1<void, ThreadPoolGateway, HDConstants::TaskDef*>::operator() (this=0x606ac40, p=0x252bda0, a1=0x3b792f0) at /usr/local/include/boost/bind/mem_fn_template.hpp:165 #12 0x00000000007261fd in boost::_bi::list2<boost::_bi::value<ThreadPoolGateway*>, boost::_bi::value<HDConstants::TaskDef*> >::operator()<boost::_mfi::mf1<void, ThreadPoolGateway, HDConstants::TaskDef*>, boost::_bi::list0> (this=0x606ac50, f=..., a=...) at /usr/local/include/boost/bind/bind.hpp:319 #13 0x0000000000725fc5 in boost::_bi::bind_t<void, boost::_mfi::mf1<void, ThreadPoolGateway, HDConstants::TaskDef*>, boost::_bi::list2<boost::_bi::value<ThreadPoolGateway*>, boost::_bi::value<HDConstants::TaskDef*> > >::operator() (this=0x606ac40) at /usr/local/include/boost/bind/bind.hpp:1294 #14 0x0000000000725eea in boost::detail::function::void_function_obj_invoker0<boost::_bi::bind_t<void, boost::_mfi::mf1<void, ThreadPoolGateway, HDConstants::TaskDef*>, boost::_bi::list2<boost::_bi::value<ThreadPoolGateway*>, boost::_bi::value<HDConstants::TaskDef*> > >, void>::invoke (function_obj_ptr=...) at /usr/local/include/boost/function/function_template.hpp:159 #15 0x0000000000660f7e in boost::function0<void>::operator() (this=0x7fd58890fa80) at /usr/local/include/boost/function/function_template.hpp:760 ---Type <return> to continue, or q <return> to quit--- #16 0x000000000067cc94 in boost::threadpool::detail::pool_core<boost::function0<void>, boost::threadpool::fifo_scheduler, boost::threadpool::static_size, boost::threadpool::resize_controller, boost::threadpool::wait_for_all_tasks>::execute_task (this=0x258c180) at /usr/local/include/boost/threadpool/detail/pool_core.hpp:440 #17 0x000000000067bd44 in boost::threadpool::detail::worker_thread<boost::threadpool::detail::pool_core<boost::function0<void>, boost::threadpool::fifo_scheduler, boost::threadpool::static_size, boost::threadpool::resize_controller, boost::threadpool::wait_for_all_tasks> >::run (this=0x25a0150) at /usr/local/include/boost/threadpool/detail/worker_thread.hpp:82 #18 0x000000000067f4ee in boost::_mfi::mf0<void, boost::threadpool::detail::worker_thread<boost::threadpool::detail::pool_core<boost::function0<void>, boost::threadpool::fifo_scheduler, boost::threadpool::static_size, boost::threadpool::resize_controller, boost::threadpool::wait_for_all_tasks> > >::call<boost::shared_ptr<boost::threadpool::detail::worker_thread<boost::threadpool::detail::pool_core<boost::function0<void>, boost::threadpool::fifo_scheduler, boost::threadpool::static_size, boost::threadpool::resize_controller, boost::threadpool::wait_for_all_tasks> > > > (this=0x2571298, u=...) at /usr/local/include/boost/bind/mem_fn_template.hpp:40 #19 0x000000000067f473 in boost::_mfi::mf0<void, boost::threadpool::detail::worker_thread<boost::threadpool::detail::pool_core<boost::function0<void>, boost::threadpool::fifo_scheduler, boost::threadpool::static_size, boost::threadpool::resize_controller, boost::threadpool::wait_for_all_tasks> > >::operator()<boost::shared_ptr<boost::threadpool::detail::worker_thread<boost::threadpool::detail::pool_core<boost::function0<void>, boost::threadpool::fifo_scheduler, boost::threadpool::static_size, boost::threadpool::resize_controller, boost::threadpool::wait_for_all_tasks> > > > (this=0x2571298, u=...) at /usr/local/include/boost/bind/mem_fn_template.hpp:55 #20 0x000000000067f41e in boost::_bi::list1<boost::_bi::value<boost::shared_ptr<boost::threadpool::detail::worker_thread<boost::threadpool::detail::pool_core<boost::function0<void>, boost::threadpool::fifo_scheduler, boost::threadpool::static_size, boost::threadpool::resize_controller, boost::threadpool::wait_for_all_tasks> > > > >::operator()<boost::_mfi::mf0<void, boost::threadpool::detail::worker_thread<boost::threadpool::detail::pool_core<boost::function0<void>, boost::threadpool::fifo_scheduler, boost::threadpool::static_size, boost::threadpool::resize_controller, boost::threadpool::wait_for_all_tasks> > >, boost::_bi::list0> (this=0x25712a8, f=..., a=...) at /usr/local/include/boost/bind/bind.hpp:259 #21 0x000000000067f303 in boost::_bi::bind_t<void, boost::_mfi::mf0<void, boost::threadpool::detail::worker_thread<boost::threadpool::detail::pool_core<boost::function0<void>, boost::threadpool::fifo_scheduler, boost::threadpool::static_size, boost::threadpool::resize_controller, boost::threadpool::wait_for_all_tasks> > >, boost::_bi::list1<boost::_bi::value<boost::shared_ptr<boost::threadpool::detail::worker_thread<boost::threadpool::detail::pool_core<boost::function0<void>, boost::threadpool::fifo_scheduler, boost::threadpool::static_size, boost::threadpool::resize_controller, boost::threadpool::wait_for_all_tasks> > > > > >::operator() (this=0x2571298) at /usr/local/include/boost/bind/bind.hpp:1294 #22 0x000000000067f0ee in boost::detail::thread_data<boost::_bi::bind_t<void, boost::_mfi::mf0<void, boost::threadpool::detail::worker_---Type <return> to continue, or q <return> to quit--- thread<boost::threadpool::detail::pool_core<boost::function0<void>, boost::threadpool::fifo_scheduler, boost::threadpool::static_size, boost::threadpool::resize_controller, boost::threadpool::wait_for_all_tasks> > >, boost::_bi::list1<boost::_bi::value<boost::shared_ptr<boost::threadpool::detail::worker_thread<boost::threadpool::detail::pool_core<boost::function0<void>, boost::threadpool::fifo_scheduler, boost::threadpool::static_size, boost::threadpool::resize_controller, boost::threadpool::wait_for_all_tasks> > > > > > >::run ( this=0x25710e0) at /usr/local/include/boost/thread/detail/thread.hpp:116 #23 0x00007fd6bfa826d9 in thread_proxy () from ./lib/libboost_thread.so.1.64.0 #24 0x00007fd6bfeabdd5 in start_thread () from /lib64/libpthread.so.0 #25 0x00007fd6beb17ead in clone () from /lib64/libc.so.6 (gdb) (gdb) (gdb) f 9 #9 0x000000000069b836 in InformationCommand::Process (this=0x7ec8a38, task=..., response=@0x7fd58890f3f8: 0x0) at src/modules/DataCommand/InformationCommand.cpp:74 74 src/modules/DataCommand/InformationCommand.cpp: No such file or directory. (gdb) p task $1 = (const HDConstants::TaskDef &) @0x3b792f0: {data = 0x4537b60, socket = 0x3122000, clientAddr = 3748199939, clientPort = 33385, msgType = (unknown: 0), protocol = 2} (gdb) p task.data.size $2 = 71 (gdb) p serialNum $3 = 4623 (gdb) ``` ![Core源码位置](https://img-ask.csdn.net/upload/201912/05/1575510670_285044.png)
c++内存问题!!!!!!!
#include <iostream> #include <string> #include <vector> using namespace std; int main() { string a, b; int i, x, y; vector<string> v1, v2; while (cin >> a >> b) { for (i = 0; i < v1.size(); i++) { if (v1[i] == a) { x = i; break; } } if (i == v1.size()) x = i; for (i = 0; i < v2.size(); i++) { if (v2[i] == b) { y = i; break; } } if (i == v2.size()) y = i; if (x == v1.size() && y == v2.size()) { cout << b << " registered." << endl; v1.push_back(a); v2.push_back(b); } else if (v1[y] == a && v2[x] == b) { cout << b << " signed in." << endl; } else if (x != v1.size() && y == v2.size()) { cout << "GOTCHA: MAC address already occupied by "; cout << v2[x] << "." << endl; } else { cout << "GOTCHA: " << b << " MAC address not consistent." << endl; } } return 0; } Invalid read of size 8 | at 0x3F8CC9C0D0: std::string::size() const (in /usr/lib64/libstdc++.so.6.0.13) | by 0x40175D: __gnu_cxx::__enable_if<std::__is_char<char>::__value, bool>::__type std::operator==<char>(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (basic_string.h:2243) | by 0x4012B5: main (main.cpp:30) | Address 0x4c29498 is 8 bytes before a block of size 8 alloc'd | at 0x4A075BC: operator new(unsigned long) (vg_replace_malloc.c:298) | by 0x402184: __gnu_cxx::new_allocator<std::string>::allocate(unsigned long, void const*) (new_allocator.h:89) | by 0x401F80: std::_Vector_base<std::string, std::allocator<std::string> >::_M_allocate(unsigned long) (stl_vector.h:140) | by 0x401BBB: std::vector<std::string, std::allocator<std::string> >::_M_insert_aux(__gnu_cxx::__normal_iterator<std::string*, std::vector<std::string, std::allocator<std::string> > >, std::string const&) (vector.tcc:322) | by 0x401877: std::vector<std::string, std::allocator<std::string> >::push_back(std::string const&) (stl_vector.h:741) | by 0x40122E: main (main.cpp:27) | |Invalid read of size 8 | at 0x3F8CC9C0D3: std::string::size() const (in /usr/lib64/libstdc++.so.6.0.13) | by 0x40175D: __gnu_cxx::__enable_if<std::__is_char<char>::__value, bool>::__type std::operator==<char>(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (basic_string.h:2243) | by 0x4012B5: main (main.cpp:30) | Address 0xffffffffffffffe8 is not stack'd, malloc'd or (recently) free'd | | |Process terminating with default action of signal 11 (SIGSEGV) | Access not within mapped region at address 0xFFFFFFFFFFFFFFE8 | at 0x3F8CC9C0D3: std::string::size() const (in /usr/lib64/libstdc++.so.6.0.13) | by 0x40175D: __gnu_cxx::__enable_if<std::__is_char<char>::__value, bool>::__type std::operator==<char>(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (basic_string.h:2243) | by 0x4012B5: main (main.cpp:30) | If you believe this happened as a result of a stack | overflow in your program's main thread (unlikely but | possible), you can try to increase the size of the | main thread stack using the --main-stacksize= flag. | The main thread stack size used in this run was 10485760. |66 bytes in 2 blocks are possibly lost in loss record 3 of 4 | at 0x4A075BC: operator new(unsigned long) (vg_replace_malloc.c:298) | by 0x3F8CC9C3C8: std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&) (in /usr/lib64/libstdc++.so.6.0.13) | by 0x3F8CC9D19A: std::string::_Rep::_M_clone(std::allocator<char> const&, unsigned long) (in /usr/lib64/libstdc++.so.6.0.13) | by 0x3F8CC9D5EB: std::string::reserve(unsigned long) (in /usr/lib64/libstdc++.so.6.0.13) | by 0x3F8CC7B05A: std::basic_istream<char, std::char_traits<char> >& std::operator>><char, std::char_traits<char>, std::allocator<char> >(std::basic_istream<char, std::char_traits<char> >&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >&) (in /usr/lib64/libstdc++.so.6.0.13) | by 0x401431: main (main.cpp:8) | |114 bytes in 2 blocks are possibly lost in loss record 4 of 4 | at 0x4A075BC: operator new(unsigned long) (vg_replace_malloc.c:298) | by 0x3F8CC9C3C8: std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&) (in /usr/lib64/libstdc++.so.6.0.13) | by 0x3F8CC9D19A: std::string::_Rep::_M_clone(std::allocator<char> const&, unsigned long) (in /usr/lib64/libstdc++.so.6.0.13) | by 0x3F8CC9D5EB: std::string::reserve(unsigned long) (in /usr/lib64/libstdc++.so.6.0.13) | by 0x3F8CC7B05A: std::basic_istream<char, std::char_traits<char> >& std::operator>><char, std::char_traits<char>, std::allocator<char> >(std::basic_istream<char, std::char_traits<char> >&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >&) (in /usr/lib64/libstdc++.so.6.0.13) | by 0x40141F: main (main.cpp:8) 怎么破! 求大神
新人求指导 c++primer书中例子
P190例子 #include<iostream> #include<string> using namespace std; string::size_type find_char(const string &s, char c, string::size_type &occurs) { auto ret = s.size(); occurs = 0; for (decltype(ret)i = 0; i != s.size(); ++i){ if (s[i] == c){ if (ret == s.size()) ret = i; ++occurs; } } return ret; } int main(){ string a("ewusruywsoieuyruwaufbnsdbyfeywaryawiuruaiwhruwhfadsfsf"); char b = 's'; string::size_type m = 0; cout << find_char(a, b, m) << '\n'<< m << endl; return 0; } 这里m输出的值为0,为什么不是字符s出现的次数呢?哪里编写错了吗?
C++ primer第五版例子编译出错
请教,中文第五版p190页的例子编译出错,不知道错哪里了,求大神指正,感激不尽。 错误提示:expected unqualified-id before ')' token 代码如下: # include <iostream> # include <cstring> using namespace std; string::size_type() find_char(const string &s, char c, string::size_type() &occurs) { auto ret = s.size(); //ret记录第一次出现的位置 occurs = 0; for(decltype(ret) i = 0; i != s.size(); ++i) { if(s[i] == c) { if(ret == s.size()) ret = i; ++occurs; } } return ret; } int main() { string::size_type() ctr = 0; find_char("Hello World!",'o',ctr); return 0; }
求教这个c++程序哪里有错
求教这个c++程序哪里有错 每次编译都会说“delete”: 不能删除不是指针的对象。 程序我是照着c++ primer打的。有些搞不明白哪里用了delete。 #include<iostream> #include<memory> #include<string> #include<vector> #include<list> using namespace std; class StrBlob { public: typedef vector<string>::size_type size_type; StrBlob(); StrBlob(initializer_list<string> il); size_type size() const { return data->size(); } bool empty() const { return data->empty(); } //添加删除 void push_back(const string &t) { data->push_back(t); } void pop_back(); //元素访问 string& front(); string& back(); private: shared_ptr<vector<string>> data; void check(size_type i, const string &msg) const; }; StrBlob::StrBlob() : data(make_shared<vector<string>>) { } StrBlob::StrBlob(initializer_list<string> il) : data(make_shared<vector<string>> (il)) { } void StrBlob::check(size_type i, const string &msg) const { if (i >= data->size()) { throw out_of_range(msg); } } string& StrBlob::front() { check(0, "front on empty StrBlob"); return data->front(); } string& StrBlob::back() { check(0, "back on empty StrBlob"); return data->back(); } void StrBlob::pop_back() { check(0, "no data on the vector"); data->pop_back(); } int main() { StrBlob a({ "a", "b", "c" }); StrBlob b = a; cout << b.size(); getchar(); }
string为什么会死循环
for(string::size_type ix=str.size()-1;ix>=0;ix--) { cout<<str[ix];}
: file(new vector<string>) 是怎么初始化的?
``` class Query_result; class Text_query { public: using line_no = vector<std::string>::size_type; Text_query(ifstream&); Query_result query(const string&) const; private: shared_ptr<vector<string>> file; map<string, shared_ptr<set<line_no>>> wm; }; Text_query::Text_query(ifstream &is) : file(new vector<string>)//这里 { string text; while (getline(is, text)) { file->push_back(text); int n = file->size() - 1; istringstream line(text); string word; while (line >> word) { auto &lines = wm[word]; if (!lines) lines.reset(new set <line_no>); lines->insert(n); } } } ``` 《C++ Primer》第五版,中文版。 433 页。
ccf 2015年9月的第三题的一个问题
ccf 2015年9月第三题,是一个简单的字符串替换的程序,但是我的程序好像都没有正常读入输入,求大佬帮忙看一下 ![图片说明](https://img-ask.csdn.net/upload/201910/04/1570194572_512584.jpg) ![图片说明](https://img-ask.csdn.net/upload/201910/04/1570194584_846073.jpg) ``` #include<iostream> #include<string> using namespace std; void string_replace( std::string &strBig, const std::string &strsrc, const std::string &strdst) { std::string::size_type pos = 0; std::string::size_type srclen = strsrc.size(); std::string::size_type dstlen = strdst.size(); while( (pos=strBig.find(strsrc, pos)) != std::string::npos ) { strBig.replace( pos, srclen, strdst ); pos += dstlen; } } int main() { int line_num=0,replace_num=0; cin>>line_num>>replace_num; string *input=new string[line_num]; for(int n=0;n<line_num;n++) { getline(cin,input[n]); } string *re_from=new string[replace_num]; string *re_to=new string[replace_num]; for(int n=0;n<replace_num;n++) { //cout<<'+'<<'\n'; cin>>re_from[n]>>re_to[n]; } for(int n=0;n<line_num;n++) { string tem1="{{ "+re_from[n]+" }}"; string tem2=re_to[n].substr(1,re_to[n].length()-1); string_replace(input[n],tem1,tem2); } for(int n=0;n<line_num;n++) cout<<input[n]<<'\n'; return 0; } ```
关于cout对函数输出的问题
#if 1 #include<iostream> #include<string> using namespace std; string::size_type find_char(const string &s, char c, string::size_type &occurs) { auto ret = s.size(); occurs = 0; for (decltype(ret)i = 0; i != s.size(); ++i){ if (s[i] == c){ if (ret == s.size()) ret = i; ++occurs; } } return ret; } int main(){ string a("ewusruywsoieuyruwaufbnsdbyfeywaryawiuruaiwhruwhfadsfsf"); char b = 's'; string::size_type m = 0; /*此处之所以输出的m为最初定义时候的值*/ //cout << find_char(a, b, m) << '\n' << m << endl; auto s = find_char(a, b, m); cout << s << '\n' << m << endl; return 0; } #endif
C++对Spring类进行replace操作报错问题
在子函数中对Spring类进行操作,结果报错,代码和错误原因如下。。。 请各位大佬给小白一些帮助。。。 #include <iostream> #include <fstream> #include <sstream> #include <string.h> #include <vector> using namespace std; int analyse_line(const string& str) { string P=","; string s; int count = 0; int begin=-1; int t = 0; while((begin=str.find(P,begin+1))!=string::npos) { char i = str[begin+1]; char j = str[begin-1]; char k = '\"'; count++; if ( i == k | j == k){} else { str.replace(begin,1,"/");//出错位置 } begin=begin+P.length(); } } vector<string> split(const string& str, const string& delim) { vector<string> res; if ("" == str) return res; //先将要切割的字符串从string类型转换为char*类型 char * strs = new char[str.length() + 1]; //不要忘了 strcpy(strs, str.c_str()); char * d = new char[delim.length() + 1]; strcpy(d, delim.c_str()); char *p = strtok(strs, d); while (p) { string s = p; //分割得到的字符串转换为string类型 res.push_back(s); //存入结果数组 p = strtok(NULL, d); } return res; } int main() { ifstream fin("d.csv"); //打开文件流操作 string line; while (getline(fin, line)) //整行读取,换行符“\n”区分,遇到文件尾标志eof终止读取 { analyse_line(line); //string &replace(int p0, int n0,int n, char c); std::vector<string> res = split(line, ","); } return 0; } 错误原因:28 26 [Error] passing 'const string {aka const std::basic_string<char>}' as 'this' argument of 'std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT, _Traits, _Alloc>::replace(std::basic_string<_CharT, _Traits, _Alloc>::size_type, std::basic_string<_CharT, _Traits, _Alloc>::size_type, const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::basic_string<_CharT, _Traits, _Alloc>::size_type = long long unsigned int]' discards qualifiers [-fpermissive]
求教C++大神: 错误 2 error C2064: 项不会计算为接受 2 个参数的函数
``` #include<iostream> #include<vector> #include<string> #include<algorithm> void biggies(vector<string> &words, vector<string>::size_type sz); int main() { vector<string> svec{ "welcom", "to", "beijing", "china", "welcom", "to", "hefei", "china" }; biggies(svec, 3); return 0; } void biggies(vector<string> &words, vector<string>::size_type sz) { sort(words.begin(), words.end()); stable_sort(words.begin(), words.end(),[sz](const string &a){ return a.size() >sz; }); } ```
leetcode100,想使用智能指针但是出错,请问为什么?
代码如下: ```c /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ class Solution { public: bool isSameTree(TreeNode* p, TreeNode* q) { stack<shared_ptr<TreeNode>> s1, s2; if (p) { s1.push(shared_ptr<TreeNode>(p)); } if (q) { s1.push(make_shared<TreeNode>(q)); } while (!s1.empty() && !s2.empty()) { shared_ptr<TreeNode> pT = s1.top(); s1.pop(); shared_ptr<TreeNode> qT = s2.top(); s2.pop(); if (pT->val != qT->val) { return false; } if (pT->left) { s1.push(make_shared<TreeNode>(pT->left)); } if (qT->left) { s2.push(make_shared<TreeNode>(qT->left)); } if (s1.size() != s2.size()) { return false; } if (pT->right) { s1.push(make_shared<TreeNode>(pT->right)); } if (qT->right) { s2.push(make_shared<TreeNode>(qT->right)); } if (s1.size() != s2.size()) { return false; } } return false; } }; ``` 代码错误提示如下: In file included from /usr/local/include/c++/6.3.0/x86_64-linux-gnu/bits/c++allocator.h:33:0, from /usr/local/include/c++/6.3.0/bits/allocator.h:46, from /usr/local/include/c++/6.3.0/string:41, from /usr/local/include/c++/6.3.0/bits/locale_classes.h:40, from /usr/local/include/c++/6.3.0/bits/ios_base.h:41, from /usr/local/include/c++/6.3.0/ios:42, from /usr/local/include/c++/6.3.0/ostream:38, from /usr/local/include/c++/6.3.0/iostream:39, from headers.h:1: /usr/local/include/c++/6.3.0/ext/new_allocator.h: In instantiation of 'void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = TreeNode; _Args = {TreeNode*&}; _Tp = TreeNode]': /usr/local/include/c++/6.3.0/bits/alloc_traits.h:455:4: required from 'static void std::allocator_traits<std::allocator<_CharT> >::construct(std::allocator_traits<std::allocator<_CharT> >::allocator_type&, _Up*, _Args&& ...) [with _Up = TreeNode; _Args = {TreeNode*&}; _Tp = TreeNode; std::allocator_traits<std::allocator<_CharT> >::allocator_type = std::allocator<TreeNode>]' /usr/local/include/c++/6.3.0/bits/shared_ptr_base.h:520:39: required from 'std::_Sp_counted_ptr_inplace<_Tp, _Alloc, _Lp>::_Sp_counted_ptr_inplace(_Alloc, _Args&& ...) [with _Args = {TreeNode*&}; _Tp = TreeNode; _Alloc = std::allocator<TreeNode>; __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2u]' /usr/local/include/c++/6.3.0/bits/shared_ptr_base.h:615:4: required from 'std::__shared_count<_Lp>::__shared_count(std::_Sp_make_shared_tag, _Tp*, const _Alloc&, _Args&& ...) [with _Tp = TreeNode; _Alloc = std::allocator<TreeNode>; _Args = {TreeNode*&}; __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2u]' /usr/local/include/c++/6.3.0/bits/shared_ptr_base.h:1100:35: required from 'std::__shared_ptr<_Tp, _Lp>::__shared_ptr(std::_Sp_make_shared_tag, const _Alloc&, _Args&& ...) [with _Alloc = std::allocator<TreeNode>; _Args = {TreeNode*&}; _Tp = TreeNode; __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2u]' /usr/local/include/c++/6.3.0/bits/shared_ptr.h:319:64: required from 'std::shared_ptr<_Tp>::shared_ptr(std::_Sp_make_shared_tag, const _Alloc&, _Args&& ...) [with _Alloc = std::allocator<TreeNode>; _Args = {TreeNode*&}; _Tp = TreeNode]' /usr/local/include/c++/6.3.0/bits/shared_ptr.h:619:14: required from 'std::shared_ptr<_Tp1> std::allocate_shared(const _Alloc&, _Args&& ...) [with _Tp = TreeNode; _Alloc = std::allocator<TreeNode>; _Args = {TreeNode*&}]' /usr/local/include/c++/6.3.0/bits/shared_ptr.h:635:39: required from 'std::shared_ptr<_Tp1> std::make_shared(_Args&& ...) [with _Tp = TreeNode; _Args = {TreeNode*&}]' Line 18: Char 44: required from here /usr/local/include/c++/6.3.0/ext/new_allocator.h:120:4: error: invalid conversion from 'TreeNode*' to 'int' [-fpermissive] { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); } ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 我寻思使用make_shared<>也不会让TreeNode*变成int啊,而且直接使用构造函数就可以,太奇怪了
VS2013,C++,error LNK2019和LNK1120
output:1>------ Build started: Project: chapter5 使用序列式容器并分析字符串, Configuration: Debug Win32 ------ 1> Source.cpp 1>Source.obj : error LNK2019: unresolved external symbol "class std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > __cdecl split(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &)" (?split@@YA?AV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@AAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z) referenced in function _main 1>C:\Users\cc\Desktop\Accelerated C++\exercise\chapter5 使用序列式容器并分析字符串\Debug\chapter5 使用序列式容器并分析字符串.exe : fatal error LNK1120: 1 unresolved externals ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== split.cpp: > //使用索引实现的split函数 #include <string> #include <vector> #include <iostream> #include <cctype> using namespace std; vector<string> split(const string &s) { vector<string> ret; typedef string::size_type string_size; string_size i = 0; while (i != s.size()) { while (i != s.size() && isspace(s[i])) ++i; string_size j = i; while (j != s.size() && !isspace(s[j])) ++j; if (i != j) { ret.push_back(s.substr(i, j - i)); i = j; } } return ret; } ===== split.h: > #ifndef GUARD_split_h #define GUARD_split_h #include <vector> #include <string> std::vector<std::string> split(std::string &s); #endif ===== Source.cpp > #include "split.h" #include <iostream> #include <string> #include <vector> #include <iterator> using namespace std; int main() { string s; while (getline(cin, s)) { vector<string> v = split(s); for (vector<string>::size_type i = 0; i != v.size(); ++i) cout << v[i] << endl; } return 0; } ====== 我用的是空项目建立的,搞不懂是为什么出问题了,新手啊
这个 shared_ptr 在使用的时候为什么要 reset?
``` class Query_result; class Text_query { public: using line_no = vector<std::string>::size_type; Text_query(ifstream&); Query_result query(const string&) const; private: shared_ptr<vector<string>> file; map<string, shared_ptr<set<line_no>>> wm;//这里 }; Text_query::Text_query(ifstream &is) : file(new vector<string>) { string text; while (getline(is, text)) { file->push_back(text); int n = file->size() - 1; istringstream line(text); string word; while (line >> word) { auto &lines = wm[word]; if (!lines) lines.reset(new set <line_no>);//这里 lines->insert(n); } } } ``` 《C++ Primer》第五版,中文版。 433 页。书上的解释看不明白。
程序无法启动。。。系统找不到指定文件
#include"stdafx.h" #include<afx.h> #include <opencv2/opencv.hpp> #include <iostream> using namespace cv; using namespace std; int main(){ CString abPath = "C:\\Profram Files\\feiq\\Recv Files\\ACSImage\\cache\\v3.2\\代表图"; getFile(abPath); } void changeSize(CString cs_abPath,string abSavePath,CString fileName){ Mat img = imread(cs_abPath.GetBuffer); Mat dst; string savePath = abSavePath +"\\" +fileName.GetBuffer+".jpg"; double scale; int img_height = img.rows; scale = 400.0/ img_height; resize(img, dst, Size(0, 0), scale, scale); imwrite(savePath,dst); } void getFile(CString pathStr){ CString myDataPath, fdPath; myDataPath =pathStr+"\\*.*"; CFileFind finder; boolean buffer = finder.FindFile(myDataPath); string abSavePath = "C:\\Profram Files\\feiq\\Recv Files\\ACSImage\\cache\\v3.2\\代表图小图"; while (buffer) { buffer = finder.FindNextFileW(); if (!finder.IsDots){ /*fdPath是当前的路径, 判断: 如果当前这个路径下是文件夹 递归(fdPath) 如果当前这个路径下是文件 则调changeSize() 多个文件的可以吗?? 保存文件的路径怎么办?? 逻辑上还是有问题 */ fdPath = finder.GetFilePath; if (finder.IsDirectory) { getFile(fdPath); } else { changeSize(fdPath, abSavePath, finder.GetFileName()); } } } finder.Close(); } 代码如上 win32AP 我想不用MFC然后调用MFC里的一些类, 出现题目所示问题. 1>------ Build started: Project: opencvTestBYljk, Configuration: Debug Win32 ------ 1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppBuild.targets(364,5): warning MSB8004: Output Directory does not end with a trailing slash. This build instance will add the slash as it is required to allow proper evaluation of the Output Directory. 1> opencvTestBYljk.cpp 1>d:\lx\home\proj\cuda\opencvtestbyljk\opencvtestbyljk\opencvtestbyljk.cpp(10): error C3861: 'getFile': identifier not found 1>d:\lx\home\proj\cuda\opencvtestbyljk\opencvtestbyljk\opencvtestbyljk.cpp(13): error C3867: 'ATL::CSimpleStringT<wchar_t,true>::GetBuffer': function call missing argument list; use '&ATL::CSimpleStringT<wchar_t,true>::GetBuffer' to create a pointer to member 1>d:\lx\home\proj\cuda\opencvtestbyljk\opencvtestbyljk\opencvtestbyljk.cpp(15): error C2678: binary '+' : no operator found which takes a left-hand operand of type 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>' (or there is no acceptable conversion) 1> d:\opencv249\opencv\build\include\opencv2\core\mat.hpp(2001): could be 'cv::MatConstIterator cv::operator +(ptrdiff_t,const cv::MatConstIterator &)' 1> d:\opencv249\opencv\build\include\opencv2\core\mat.hpp(1998): or 'cv::MatConstIterator cv::operator +(const cv::MatConstIterator &,ptrdiff_t)' 1> d:\opencv249\opencv\build\include\opencv2\core\mat.hpp(1268): or 'cv::MatExpr cv::operator +(const cv::MatExpr &,const cv::MatExpr &)' 1> d:\opencv249\opencv\build\include\opencv2\core\mat.hpp(1267): or 'cv::MatExpr cv::operator +(const cv::Scalar &,const cv::MatExpr &)' 1> d:\opencv249\opencv\build\include\opencv2\core\mat.hpp(1266): or 'cv::MatExpr cv::operator +(const cv::MatExpr &,const cv::Scalar &)' 1> d:\opencv249\opencv\build\include\opencv2\core\mat.hpp(1265): or 'cv::MatExpr cv::operator +(const cv::Mat &,const cv::MatExpr &)' 1> d:\opencv249\opencv\build\include\opencv2\core\mat.hpp(1264): or 'cv::MatExpr cv::operator +(const cv::MatExpr &,const cv::Mat &)' 1> d:\opencv249\opencv\build\include\opencv2\core\mat.hpp(1263): or 'cv::MatExpr cv::operator +(const cv::Scalar &,const cv::Mat &)' 1> d:\opencv249\opencv\build\include\opencv2\core\mat.hpp(1262): or 'cv::MatExpr cv::operator +(const cv::Mat &,const cv::Scalar &)' 1> d:\opencv249\opencv\build\include\opencv2\core\mat.hpp(1261): or 'cv::MatExpr cv::operator +(const cv::Mat &,const cv::Mat &)' 1> d:\opencv249\opencv\build\include\opencv2\core\operations.hpp(2248): or 'cv::Range cv::operator +(int,const cv::Range &)' 1> d:\opencv249\opencv\build\include\opencv2\core\operations.hpp(2243): or 'cv::Range cv::operator +(const cv::Range &,int)' 1> while trying to match the argument list '(std::basic_string<char,std::char_traits<char>,std::allocator<char>>, overloaded-function)' 1>d:\lx\home\proj\cuda\opencvtestbyljk\opencvtestbyljk\opencvtestbyljk.cpp(31): error C2276: '!' : illegal operation on bound member function expression 1>d:\lx\home\proj\cuda\opencvtestbyljk\opencvtestbyljk\opencvtestbyljk.cpp(40): error C3867: 'CFileFind::GetFilePath': function call missing argument list; use '&CFileFind::GetFilePath' to create a pointer to member 1>d:\lx\home\proj\cuda\opencvtestbyljk\opencvtestbyljk\opencvtestbyljk.cpp(40): error C2679: binary '=' : no operator found which takes a right-hand operand of type 'overloaded-function' (or there is no acceptable conversion) 1> d:\program files (x86)\microsoft visual studio 12.0\vc\atlmfc\include\cstringt.h(1322): could be 'ATL::CStringT<wchar_t,StrTraitMFC_DLL<wchar_t,ATL::ChTraitsCRT<wchar_t>>> &ATL::CStringT<wchar_t,StrTraitMFC_DLL<wchar_t,ATL::ChTraitsCRT<wchar_t>>>::operator =(const VARIANT &)' 1> d:\program files (x86)\microsoft visual studio 12.0\vc\atlmfc\include\cstringt.h(1314): or 'ATL::CStringT<wchar_t,StrTraitMFC_DLL<wchar_t,ATL::ChTraitsCRT<wchar_t>>> &ATL::CStringT<wchar_t,StrTraitMFC_DLL<wchar_t,ATL::ChTraitsCRT<wchar_t>>>::operator =(char)' 1> d:\program files (x86)\microsoft visual studio 12.0\vc\atlmfc\include\cstringt.h(1305): or 'ATL::CStringT<wchar_t,StrTraitMFC_DLL<wchar_t,ATL::ChTraitsCRT<wchar_t>>> &ATL::CStringT<wchar_t,StrTraitMFC_DLL<wchar_t,ATL::ChTraitsCRT<wchar_t>>>::operator =(wchar_t)' 1> d:\program files (x86)\microsoft visual studio 12.0\vc\atlmfc\include\cstringt.h(1299): or 'ATL::CStringT<wchar_t,StrTraitMFC_DLL<wchar_t,ATL::ChTraitsCRT<wchar_t>>> &ATL::CStringT<wchar_t,StrTraitMFC_DLL<wchar_t,ATL::ChTraitsCRT<wchar_t>>>::operator =(const unsigned char *)' 1> d:\program files (x86)\microsoft visual studio 12.0\vc\atlmfc\include\cstringt.h(1281): or 'ATL::CStringT<wchar_t,StrTraitMFC_DLL<wchar_t,ATL::ChTraitsCRT<wchar_t>>> &ATL::CStringT<wchar_t,StrTraitMFC_DLL<wchar_t,ATL::ChTraitsCRT<wchar_t>>>::operator =(const char *)' 1> d:\program files (x86)\microsoft visual studio 12.0\vc\atlmfc\include\cstringt.h(1273): or 'ATL::CStringT<wchar_t,StrTraitMFC_DLL<wchar_t,ATL::ChTraitsCRT<wchar_t>>> &ATL::CStringT<wchar_t,StrTraitMFC_DLL<wchar_t,ATL::ChTraitsCRT<wchar_t>>>::operator =(const wchar_t *)' 1> d:\program files (x86)\microsoft visual studio 12.0\vc\atlmfc\include\cstringt.h(1258): or 'ATL::CStringT<wchar_t,StrTraitMFC_DLL<wchar_t,ATL::ChTraitsCRT<wchar_t>>> &ATL::CStringT<wchar_t,StrTraitMFC_DLL<wchar_t,ATL::ChTraitsCRT<wchar_t>>>::operator =(const ATL::CStringT<wchar_t,StrTraitMFC_DLL<wchar_t,ATL::ChTraitsCRT<wchar_t>>> &)' 1> while trying to match the argument list '(CString, overloaded-function)' 1>d:\lx\home\proj\cuda\opencvtestbyljk\opencvtestbyljk\opencvtestbyljk.cpp(41): error C3867: 'CFileFind::IsDirectory': function call missing argument list; use '&CFileFind::IsDirectory' to create a pointer to member
c++程序运行时出现string subscript out of range
int main(){ vector<string> a; string s; while(getline(cin,s)){ a=spite(s); for(vector<string>::size_type i=0;i!=a.size();i++) cout << a[i] << endl; } return 0; } -------------------------------------------------------------------------------------- vector<string> spite(【如果在这里加上const则可以正常运行】string s){ vector<string> ret; string::size_type i=0,j=0; while(i!=s.size()){ while(i!=s.size() &&isspace(s[i])) i++; j=i; while(!isspace(s[j])&&j!=s.size()) j++; if (i!=j){ ret.push_back(s.substr(i,j-i)); i=j; } } return ret; } 程序的目的是把一行句子分隔成单词输出 但是运行出现 string subscript out of range错误 如果把split函数中的参数加上const 变成const string则程序可以正常运行 这是为什么呢???
apollo3.0.0中perception问题
我对以下代码有些疑问,请大神解答: 在bool result = inst->Init(subnode_config, subnode_sub_events_map[subnode_id], subnode_pub_events_map[subnode_id],&event_manager_, &shared_data_manager_)函数中,每个节点不一定有subnode_sub_events_map和subnode_pub_events_map,这个函数在for循环中引用,不会出错吗 for (auto pair : subnode_config_map) { const DAGConfig::Subnode& subnode_config = pair.second; const SubnodeID subnode_id = pair.first; Subnode* inst = SubnodeRegisterer::GetInstanceByName(subnode_config.name()); // AINFO << "subnode_name: " << subnode_config.name(); // AINFO << "subnode_id: " << subnode_id; if (inst == NULL) { AERROR << "failed to get subnode instance. name: " << subnode_config.name(); return false; } bool result = inst->Init(subnode_config, subnode_sub_events_map[subnode_id], subnode_pub_events_map[subnode_id], &event_manager_, &shared_data_manager_); if (!result) { AERROR << "failed to Init subnode. name: " << inst->name(); return false; } subnode_map_.emplace(subnode_id, std::unique_ptr<Subnode>(inst)); subnode_name_map_[subnode_config.name()] = subnode_id; AINFO << "Init subnode succ. " << inst->DebugString(); } 以下是edge_config的配置参数 edge_config { # input nodes --> segment nodes edge. edges { id: 101 from_node: 1 to_node: 11 events { id: 1001 name: "64 lidar->segment" } } edges { id: 102 from_node: 2 to_node: 12 events { id: 1002 name: "16_0 lidar->segment" } } edges { id: 103 from_node: 3 to_node: 13 events { id: 1003 name: "16_1 lidar->segment" } } # segment nodes --> obstacle nodes edges. edges { id: 104 from_node: 11 to_node: 21 events { id: 1004 name: "64 segment -> obstacle" } } edges { id: 105 from_node: 12 to_node: 22 events { id: 1005 name: "16_0 segment -> obstacle" } } edges { id: 106 from_node: 13 to_node: 23 events { id: 1006 name: "16_1 segment -> obstacle" } } # obstacle nodes --> track nodes edges. edges { id: 107 from_node: 21 to_node: 31 events { id: 1007 name: "64 obstacle -> track" } } edges { id: 108 from_node: 22 to_node: 32 events { id: 1008 name: "16_0 obstacle -> segment" } } edges { id: 109 from_node: 23 to_node: 33 events { id: 1009 name: "16_0 obstacle -> segment" } } # track nodes --> fusion nodes edges. edges { id: 110 from_node: 31 to_node: 41 events { id: 1010 name: "64 track -> fusion" } } edges { id: 111 from_node: 32 to_node: 41 events { id: 1011 name: "16_0 track -> fusion" } } edges { id: 112 from_node: 33 to_node: 41 events { id: 1012 name: "16_1 track -> fusion" } } } 以下是subnode_pub_events_map和subnode_sub_events_map的创建代码 for (auto& edge_proto : edge_config.edges()) { SubnodeID from = edge_proto.from_node(); SubnodeID to = edge_proto.to_node(); if (subnode_config_map.find(from) == subnode_config_map.end() || subnode_config_map.find(to) == subnode_config_map.end()) { AERROR << "SubnodeID not exists in subnode_config. <" << from << ", " << to << ">"; return false; } for (auto& event_proto : edge_proto.events()) { subnode_pub_events_map[from].push_back(event_proto.id()); subnode_sub_events_map[to].push_back(event_proto.id()); } } 经过一层一层代码阅读,终于找到问题所在处: Subnode* inst = SubnodeRegisterer::GetInstanceByName(subnode_config.name());函数定义如下: bool Subnode::Init(const DAGConfig::Subnode &subnode_config, const vector<EventID> &sub_events, const vector<EventID> &pub_events, EventManager *event_manager, SharedDataManager *shared_data_manager) { name_ = subnode_config.name(); id_ = subnode_config.id(); std::cout<<id<<std::endl; reserve_ = subnode_config.reserve(); if (subnode_config.has_type()) { type_ = subnode_config.type(); } CHECK(event_manager != nullptr) << "event_manager == nullptr"; event_manager_ = event_manager; CHECK(shared_data_manager != nullptr) << "shared_data_manager == nullptr"; shared_data_manager_ = shared_data_manager; // fill sub and pub meta events. if (!event_manager_->GetEventMeta(sub_events, &sub_meta_events_)) { AERROR << "failed to get Sub EventMeta. node: <" << name_ << ", " << id_ << ">"; return false; } if (!event_manager_->GetEventMeta(pub_events, &pub_meta_events_)) { AERROR << "failed to get Pub EventMeta. node: <" << id_ << ", " << name_ << ">"; return false; } if (!InitInternal()) { AERROR << "failed to Init inner members."; return false; } inited_ = true; return true; } event_manager_->GetEventMeta函数定义如下,由for循环判断是否决定添 加事件,这样pub和sub事件的存在与否问题解决了 bool EventManager::GetEventMeta(const vector<EventID> &event_ids, vector<string> *str_list) const { str_list->reserve(event_ids.size()); for (EventID event_id : event_ids) { string str; if (!GetEventMeta(event_id, &str)) { return false; } str_list->push_back(str); } return true; }
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
动态规划入门到熟悉,看不懂来打我啊
持续更新。。。。。。 2.1斐波那契系列问题 2.2矩阵系列问题 2.3跳跃系列问题 3.1 01背包 3.2 完全背包 3.3多重背包 3.4 一些变形选讲 2.1斐波那契系列问题 在数学上,斐波纳契数列以如下被以递归的方法定义:F(0)=0,F(1)=1, F(n)=F(n-1)+F(n-2)(n&gt;=2,n∈N*)根据定义,前十项为1, 1, 2, 3...
程序员,职场上请远离这种人!
对有些职场人来讲,甩锅就是一种生存手段。01.从大学打篮球说起上大学的时候喜欢打篮球,然后我又特别喜欢抢篮板,经常是跳起来的时候没事,落下来的时候偶尔会踩到别人的脚上,于...
终于明白阿里百度这样的大公司,为什么面试经常拿ThreadLocal考验求职者了
点击上面↑「爱开发」关注我们每晚10点,捕获技术思考和创业资源洞察什么是ThreadLocalThreadLocal是一个本地线程副本变量工具类,各个线程都拥有一份线程私...
对计算机专业来说学历真的重要吗?
我本科学校是渣渣二本,研究生学校是985,现在毕业五年,校招笔试、面试,社招面试参加了两年了,就我个人的经历来说下这个问题。 这篇文章很长,但绝对是精华,相信我,读完以后,你会知道学历不好的解决方案,记得帮我点赞哦。 先说结论,无论赞不赞同,它本质就是这样:对于技术类工作而言,学历五年以内非常重要,但有办法弥补。五年以后,不重要。 目录: 张雪峰讲述的事实 我看到的事实 为什么会这样 ...
Java学习的正确打开方式
在博主认为,对于入门级学习java的最佳学习方法莫过于视频+博客+书籍+总结,前三者博主将淋漓尽致地挥毫于这篇博客文章中,至于总结在于个人,实际上越到后面你会发现学习的最好方式就是阅读参考官方文档其次就是国内的书籍,博客次之,这又是一个层次了,这里暂时不提后面再谈。博主将为各位入门java保驾护航,各位只管冲鸭!!!上天是公平的,只要不辜负时间,时间自然不会辜负你。 何谓学习?博主所理解的学习,它是一个过程,是一个不断累积、不断沉淀、不断总结、善于传达自己的个人见解以及乐于分享的过程。
程序员必须掌握的核心算法有哪些?
由于我之前一直强调数据结构以及算法学习的重要性,所以就有一些读者经常问我,数据结构与算法应该要学习到哪个程度呢?,说实话,这个问题我不知道要怎么回答你,主要取决于你想学习到哪些程度,不过针对这个问题,我稍微总结一下我学过的算法知识点,以及我觉得值得学习的算法。这些算法与数据结构的学习大多数是零散的,并没有一本把他们全部覆盖的书籍。下面是我觉得值得学习的一些算法以及数据结构,当然,我也会整理一些看过
Python——画一棵漂亮的樱花树(不同种樱花+玫瑰+圣诞树喔)
最近翻到一篇知乎,上面有不少用Python(大多是turtle库)绘制的树图,感觉很漂亮,我整理了一下,挑了一些我觉得不错的代码分享给大家(这些我都测试过,确实可以生成) one 樱花树 动态生成樱花 效果图(这个是动态的): 实现代码 import turtle as T import random import time # 画樱花的躯干(60,t) def Tree(branch, ...
大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了
大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...
一个读研让我损失了一百万的真实故事
关注我!只要10分钟,包你学会数据分析 毕业后,应该就业还是考研? 我刚出国留学那会儿,就惊讶的发现,外国local95%都不会选择读研 他们说,硕士学费很贵,时间宝贵,老板不认,所以很费 当几乎所有人都是本科学历时,硕士学历反而像个异类 在老板眼里,三年硕士远远不如3年的工作经验实用 他们甚至专门为拒绝高学历者发明了一个词,叫overoccupie...
Python 植物大战僵尸代码实现(2):植物卡片选择和种植
这篇文章要介绍的是: - 上方植物卡片栏的实现。 - 点击植物卡片,鼠标切换为植物图片。 - 鼠标移动时,判断当前在哪个方格中,并显示半透明的植物作为提示。
西游记团队中如果需要裁掉一个人,会先裁掉谁?
2019年互联网寒冬,大批企业开始裁员,下图是网上流传的一张截图: 裁员不可避免,那如何才能做到不管大环境如何变化,自身不受影响呢? 我们先来看一个有意思的故事,如果西游记取经团队需要裁员一名,会裁掉谁呢,为什么? 西游记团队组成: 1.唐僧 作为团队teamleader,有很坚韧的品性和极高的原则性,不达目的不罢休,遇到任何问题,都没有退缩过,又很得上司支持和赏识(直接得到唐太宗的任命,既给
shell脚本:备份数据库、代码上线
备份MySQL数据库 场景: 一台MySQL服务器,跑着5个数据库,在没有做主从的情况下,需要对这5个库进行备份 需求: 1)每天备份一次,需要备份所有的库 2)把备份数据存放到/data/backup/下 3)备份文件名称格式示例:dbname-2019-11-23.sql 4)需要对1天以前的所有sql文件压缩,格式为gzip 5)本地数据保留1周 6)需要把备份的数据同步到远程备份中心,假如...
聊聊C语言和指针的本质
坐着绿皮车上海到杭州,24块钱,很宽敞,在火车上非正式地聊几句。 很多编程语言都以 “没有指针” 作为自己的优势来宣传,然而,对于C语言,指针却是与生俱来的。 那么,什么是指针,为什么大家都想避开指针。 很简单, 指针就是地址,当一个地址作为一个变量存在时,它就被叫做指针,该变量的类型,自然就是指针类型。 指针的作用就是,给出一个指针,取出该指针指向地址处的值。为了理解本质,我们从计算机模型说起...
为什么你学不过动态规划?告别动态规划,谈谈我的经验
动态规划难吗?说实话,我觉得很难,特别是对于初学者来说,我当时入门动态规划的时候,是看 0-1 背包问题,当时真的是一脸懵逼。后来,我遇到动态规划的题,看的懂答案,但就是自己不会做,不知道怎么下手。就像做递归的题,看的懂答案,但下不了手,关于递归的,我之前也写过一篇套路的文章,如果对递归不大懂的,强烈建议看一看:为什么你学不会递归,告别递归,谈谈我的经验 对于动态规划,春招秋招时好多题都会用到动态...
程序员一般通过什么途径接私活?
二哥,你好,我想知道一般程序猿都如何接私活,我也想接,能告诉我一些方法吗? 上面是一个读者“烦不烦”问我的一个问题。其实不止是“烦不烦”,还有很多读者问过我类似这样的问题。 我接的私活不算多,挣到的钱也没有多少,加起来不到 20W。说实话,这个数目说出来我是有点心虚的,毕竟太少了,大家轻喷。但我想,恰好配得上“一般程序员”这个称号啊。毕竟苍蝇再小也是肉,我也算是有经验的人了。 唾弃接私活、做外...
字节跳动面试官这样问消息队列:分布式事务、重复消费、顺序消费,我整理了一下
你知道的越多,你不知道的越多 点赞再看,养成习惯 GitHub上已经开源 https://github.com/JavaFamily 有一线大厂面试点脑图、个人联系方式和人才交流群,欢迎Star和完善 前言 消息队列在互联网技术存储方面使用如此广泛,几乎所有的后端技术面试官都要在消息队列的使用和原理方面对小伙伴们进行360°的刁难。 作为一个在互联网公司面一次拿一次Offer的面霸...
如何安装 IntelliJ IDEA 最新版本——详细教程
IntelliJ IDEA 简称 IDEA,被业界公认为最好的 Java 集成开发工具,尤其在智能代码助手、代码自动提示、代码重构、代码版本管理(Git、SVN、Maven)、单元测试、代码分析等方面有着亮眼的发挥。IDEA 产于捷克,开发人员以严谨著称的东欧程序员为主。IDEA 分为社区版和付费版两个版本。 我呢,一直是 Eclipse 的忠实粉丝,差不多十年的老用户了。很早就接触到了 IDEA...
面试还搞不懂redis,快看看这40道面试题(含答案和思维导图)
Redis 面试题 1、什么是 Redis?. 2、Redis 的数据类型? 3、使用 Redis 有哪些好处? 4、Redis 相比 Memcached 有哪些优势? 5、Memcache 与 Redis 的区别都有哪些? 6、Redis 是单进程单线程的? 7、一个字符串类型的值能存储最大容量是多少? 8、Redis 的持久化机制是什么?各自的优缺点? 9、Redis 常见性...
大学四年自学走来,这些珍藏的「实用工具/学习网站」我全贡献出来了
知乎高赞:文中列举了互联网一线大厂程序员都在用的工具集合,涉及面非常广,小白和老手都可以进来看看,或许有新收获。
为什么要推荐大家学习字节码?
配套视频: 为什么推荐大家学习Java字节码 https://www.bilibili.com/video/av77600176/ 一、背景 本文主要探讨:为什么要学习 JVM 字节码? 可能很多人会觉得没必要,因为平时开发用不到,而且不学这个也没耽误学习。 但是这里分享一点感悟,即人总是根据自己已经掌握的知识和技能来解决问题的。 这里有个悖论,有时候你觉得有些技术没用恰恰是...
【超详细分析】关于三次握手与四次挥手面试官想考我们什么?
在面试中,三次握手和四次挥手可以说是问的最频繁的一个知识点了,我相信大家也都看过很多关于三次握手与四次挥手的文章,今天的这篇文章,重点是围绕着面试,我们应该掌握哪些比较重要的点,哪些是比较被面试官给问到的,我觉得如果你能把我下面列举的一些点都记住、理解,我想就差不多了。 三次握手 当面试官问你为什么需要有三次握手、三次握手的作用、讲讲三次三次握手的时候,我想很多人会这样回答: 首先很多人会先讲下握...
压测学习总结(1)——高并发性能指标:QPS、TPS、RT、吞吐量详解
一、QPS,每秒查询 QPS:Queries Per Second意思是“每秒查询率”,是一台服务器每秒能够相应的查询次数,是对一个特定的查询服务器在规定时间内所处理流量多少的衡量标准。互联网中,作为域名系统服务器的机器的性能经常用每秒查询率来衡量。 二、TPS,每秒事务 TPS:是TransactionsPerSecond的缩写,也就是事务数/秒。它是软件测试结果的测量单位。一个事务是指一...
新程序员七宗罪
当我发表这篇文章《为什么每个工程师都应该开始考虑开发中的分析和编程技能呢?》时,我从未想到它会对读者产生如此积极的影响。那些想要开始探索编程和数据科学领域的人向我寻求建议;还有一些人问我下一篇文章的发布日期;还有许多人询问如何顺利过渡到这个职业。我非常鼓励大家继续分享我在这个旅程的经验,学习,成功和失败,以帮助尽可能多的人过渡到一个充满无数好处和机会的职业生涯。亲爱的读者,谢谢你。 -罗伯特。 ...
2019年Spring Boot面试都问了什么?快看看这22道面试题!
Spring Boot 面试题 1、什么是 Spring Boot? 2、Spring Boot 有哪些优点? 3、什么是 JavaConfig? 4、如何重新加载 Spring Boot 上的更改,而无需重新启动服务器? 5、Spring Boot 中的监视器是什么? 6、如何在 Spring Boot 中禁用 Actuator 端点安全性? 7、如何在自定义端口上运行 Sprin...
【图解】记一次手撕算法面试:字节跳动的面试官把我四连击了
字节跳动这家公司,应该是所有秋招的公司中,对算法最重视的一个了,每次面试基本都会让你手撕算法,今天这篇文章就记录下当时被问到的几个算法题,并且每个算法题我都详细着给出了最优解,下面再现当时的面试场景。看完一定让你有所收获 一、小牛试刀:有效括号 大部分情况下,面试官都会问一个不怎么难的问题,不过你千万别太开心,因为这道题往往可以拓展出更多有难度的问题,或者一道题看起来很简单,但是给出最优解,确实很...
面试官:关于Java性能优化,你有什么技巧
通过使用一些辅助性工具来找到程序中的瓶颈,然后就可以对瓶颈部分的代码进行优化。 一般有两种方案:即优化代码或更改设计方法。我们一般会选择后者,因为不去调用以下代码要比调用一些优化的代码更能提高程序的性能。而一个设计良好的程序能够精简代码,从而提高性能。 下面将提供一些在JAVA程序的设计和编码中,为了能够提高JAVA程序的性能,而经常采用的一些方法和技巧。 1.对象的生成和大小的调整。 J...
【图解算法面试】记一次面试:说说游戏中的敏感词过滤是如何实现的?
版权声明:本文为苦逼的码农原创。未经同意禁止任何形式转载,特别是那些复制粘贴到别的平台的,否则,必定追究。欢迎大家多多转发,谢谢。 小秋今天去面试了,面试官问了一个与敏感词过滤算法相关的问题,然而小秋对敏感词过滤算法一点也没听说过。于是,有了下下事情的发生… 面试官开怼 面试官:玩过王者荣耀吧?了解过敏感词过滤吗?,例如在游戏里,如果我们发送“你在干嘛?麻痹演员啊你?”,由于“麻痹”是一个敏感词,...
GitHub 标星 1.6w+,我发现了一个宝藏项目,作为编程新手有福了!
大家好,我是 Rocky0429,一个最近老在 GitHub 上闲逛的蒟蒻… 特别惭愧的是,虽然我很早就知道 GitHub,但是学会逛 GitHub 的时间特别晚。当时一方面是因为菜,看着这种全是英文的东西难受,不知道该怎么去玩,另一方面是一直在搞 ACM,没有做一些工程类的项目,所以想当然的以为和 GitHub 也没什么关系(当然这种想法是错误的)。 后来自己花了一个星期看完了 Pyt...
杭漂程序员2019的心路历程,还不起助学贷款,交不起房租,披荆斩棘终雨过天晴
一个杭漂2019的心酸历程,一路披荆斩棘终于还是雨过天晴。
我采访了同事,让他掏出了每天都会浏览的干货网站
前言只有光头才能变强。文本已收录至我的GitHub精选文章,欢迎Star:https://github.com/ZhongFuCheng3y/3y在周六的晚上,我日常去到公司写文章。想写...
相关热词 c# 数组类型 泛型约束 c#的赛狗日程序 c# 传递数组 可变参数 c# 生成存储过程 c# list 补集 c#获得所有窗体 c# 当前秒数转成年月日 c#中的枚举 c# 计算校验和 连续随机数不重复c#
立即提问