Error C2662, cannot convert ‘this’ pointer from ‘const class ’ to ‘class &’

 

  1. class Point3d  
  2. {  
  3. public:  
  4.     Point3d(float x=0.0,float y=0.0,float z=0.0)  
  5.         :_x(x),_y(y),_z(z)  
  6.     {  
  7.     }  
  8.   
  9.     float GetX() {return _x;}  
  10.     float GetY() {return _y;}  
  11.     float GetZ() {return _z;}  
  12.   
  13. private:  
  14.     float _x,_y,_z;  
  15. };  
  16.   
  17. inline ostream& operator<<(ostream&out,const Point3d& pd)  
  18. {  
  19.     out<<pd.GetX()<<" "<<pd.GetY()<<" "<<pd.GetZ()<<endl;  
  20.   
  21.     return out;  
  22. }  

          

       上述的代码是导致错误的例子。错误主要的原因是const类型的对调用非const类型的方法导致的。

由于const对象在调用成员函数时,会将this指针强制转换成const this指针,它调用成员函数时会去找对应的const Get*函数,而编译器无法将非const类型的Get*函数转换成const类型的Get*函数,因此出现编译错误。

解决方法就是将Get*函数转化为const类型的函数

在对应函数后面加上const关键字

  1. class Point3d  
  2. {  
  3. public:  
  4.     Point3d(float x=0.0,float y=0.0,float z=0.0)  
  5.         :_x(x),_y(y),_z(z)  
  6.     {  
  7.     }  
  8.   
  9.     float GetX() const{return _x;}  
  10.     float GetY() const{return _y;}  
  11.     float GetZ() const{return _z;}  
  12.   
  13. private:  
  14.     float _x,_y,_z;  
  15. };  
  16.   
  17. inline ostream& operator<<(ostream&out,const Point3d& pd)  
  18. {  
  19.     out<<pd.GetX()<<" "<<pd.GetY()<<" "<<pd.GetZ()<<endl;  
  20.   
  21.     return out;  
  22. }  

        因此书《深度探索C++对象模型》第一章关于对象模型 P2页举得例子有问题的。它的代码是上面出错的代码。

 

#include &lt;iostream&gt; #include &lt;fstream&gt; #include &lt;iomanip&gt; #include &lt;vector&gt; #include &lt;string&gt; #include &lt;map&gt; #include &lt;stdexcept&gt; #include &lt;cctype&gt; // 用于字符类型判断 using namespace std; // --------------------------- 全局变量定义 --------------------------- // 预测分析表(行:非终结符,列:终结符) vector&lt;vector&lt;string&gt;&gt; table(5, vector&lt;string&gt;(9, &quot;&quot;)); // 文法产生式(索引对应非终结符顺序:E, A, T, B, F) vector&lt;string&gt; G; // 符号到索引的映射(非终结符和终结符统一编码) map&lt;char, int&gt; index; // 终结符集合(包含$作为结束符) const string terminal = &quot;in+-*/()$&quot;; // 非终结符集合(顺序与索引一致) const string nonTerminal = &quot;EATBF&quot;; // 各产生式右部的FIRST集(按G顺序) vector&lt;string&gt; First; // 非终结符的FOLLOW集(按非终结符顺序:E, A, T, B, F) vector&lt;string&gt; Follow; // --------------------------- 函数声明 --------------------------- int analysis(void); void buildTable(); // 构造分析表 // --------------------------- 主函数 --------------------------- int main() { // 初始化全局变量(VS不支持列表初始化,需逐个赋值) // 文法产生式 G.push_back(&quot;E-&gt;TA&quot;); G.push_back(&quot;A-&gt;+TA&quot;); G.push_back(&quot;A-&gt;-TA&quot;); G.push_back(&quot;A-&gt;e&quot;); G.push_back(&quot;T-&gt;FB&quot;); G.push_back(&quot;B-&gt;*FB&quot;); // 修正原代码中B-&gt;FB的错误,应为B-&gt;*FB G.push_back(&quot;B-&gt;/FB&quot;); G.push_back(&quot;B-&gt;e&quot;); G.push_back(&quot;F-&gt;i&quot;); G.push_back(&quot;F-&gt;(E)&quot;); G.push_back(&quot;F-&gt;n&quot;); // 符号索引 index[&#39;E&#39;] = 0; index[&#39;A&#39;] = 1; index[&#39;T&#39;] = 2; index[&#39;B&#39;] = 3; index[&#39;F&#39;] = 4; index[&#39;i&#39;] = 0; index[&#39;n&#39;] = 1; index[&#39;+&#39;] = 2; index[&#39;-&#39;] = 3; index[&#39;*&#39;] = 4; index[&#39;/&#39;] = 5; index[&#39;(&#39;] = 6; index[&#39;)&#39;] = 7; index[&#39;$&#39;] = 8; index[&#39;e&#39;] = 9; // 空产生式用&#39;e&#39;表示 // FIRST集(按G的顺序,共11个产生式) First.push_back(&quot;i(n&quot;); // E-&gt;TA First.push_back(&quot;+&quot;); // A-&gt;+TA First.push_back(&quot;-&quot;); // A-&gt;-TA First.push_back(&quot;e&quot;); // A-&gt;e First.push_back(&quot;i(n&quot;); // T-&gt;FB First.push_back(&quot;*&quot;); // B-&gt;*FB First.push_back(&quot;/&quot;); // B-&gt;/FB First.push_back(&quot;e&quot;); // B-&gt;e First.push_back(&quot;i&quot;); // F-&gt;i First.push_back(&quot;(&quot;); // F-&gt;(E) First.push_back(&quot;n&quot;); // F-&gt;n // FOLLOW集(按非终结符顺序:E, A, T, B, F) Follow.push_back(&quot;$)&quot;); // E的FOLLOW Follow.push_back(&quot;$)+-&quot;); // A的FOLLOW Follow.push_back(&quot;$)+-*/&quot;); // T的FOLLOW Follow.push_back(&quot;$)+-&quot;); // B的FOLLOW Follow.push_back(&quot;*/+-$)&quot;); // F的FOLLOW buildTable(); // 构造分析表 // 输出预测分析表 cout &lt;&lt; &quot;预测分析表:&quot; &lt;&lt; endl; // 输出终结符表头 for (size_t i = 0; i &lt; terminal.size(); ++i) cout &lt;&lt; &#39;\t&#39; &lt;&lt; terminal[i]; cout &lt;&lt; endl; // 输出非终结符及对应表项 for (size_t x = 0; x &lt; nonTerminal.size(); ++x) { cout &lt;&lt; nonTerminal[x]; for (size_t y = 0; y &lt; table[x].size(); ++y) cout &lt;&lt; &#39;\t&#39; &lt;&lt; table[x][y]; cout &lt;&lt; endl; } cout &lt;&lt; endl; return analysis(); } // --------------------------- 构造分析表 --------------------------- void buildTable() { // 遍历每个产生式 for (size_t itG = 0; itG &lt; G.size(); ++itG) { string prod = G[itG]; char lhs = prod[0]; // 左部非终结符 int x = index[lhs]; // 左部索引 string first = First[itG]; // 当前产生式的FIRST集 // 处理FIRST集中的非空元素 for (size_t i = 0; i &lt; first.size(); ++i) { char sym = first[i]; if (sym != &#39;e&#39;) { // 非空产生式 int y = index[sym]; if (table[x][y].empty()) { table[x][y] = prod; } } else { // 空产生式,处理FOLLOW集 string fol = Follow[index[lhs]]; // 左部非终结符的FOLLOW集 for (size_t j = 0; j &lt; fol.size(); ++j) { char folSym = fol[j]; int y = index[folSym]; if (table[x][y].empty()) { table[x][y] = prod; } } } } } // 写入同步信息(synch) for (size_t i = 0; i &lt; nonTerminal.size(); ++i) { char nt = nonTerminal[i]; int x = index[nt]; string fol = Follow[i]; // Follow集按非终结符顺序存储 for (size_t j = 0; j &lt; fol.size(); ++j) { char folSym = fol[j]; int y = index[folSym]; if (table[x][y].empty()) { table[x][y] = &quot;synch&quot;; } } } } // --------------------------- 分析过程 --------------------------- int analysis(void) { ifstream fin(&quot;fin.txt&quot;); if (!fin.is_open()) { cout &lt;&lt; &quot;输入文件不存在 fin.txt.&quot; &lt;&lt; endl; return 1; } ofstream fout(&quot;fout.txt&quot;); if (!fout.is_open()) { cout &lt;&lt; &quot;无法打开输出文件 fout.txt.&quot; &lt;&lt; endl; return 1; } string s; fin &gt;&gt; s; cout &lt;&lt; &quot;成功读取待分析串:&quot; &lt;&lt; endl &lt;&lt; s &lt;&lt; endl; int wid = s.length() + 1; s.push_back(&#39;$&#39;); // 添加结束符 vector&lt;char&gt; analyStack; analyStack.push_back(&#39;$&#39;); analyStack.push_back(&#39;E&#39;); // 初始栈:$E char top, cur; auto ip = s.begin(); // 输出格式头 fout &lt;&lt; left &lt;&lt; setw(wid + 10) &lt;&lt; &quot;栈&quot; &lt;&lt; right &lt;&lt; setw(wid) &lt;&lt; &quot;输入&quot; &lt;&lt; &quot; &quot; &lt;&lt; &quot;输出&quot; &lt;&lt; endl; do { string str1(analyStack.begin(), analyStack.end()); string str2(ip, s.end()); fout &lt;&lt; left &lt;&lt; setw(wid + 10) &lt;&lt; str1 &lt;&lt; right &lt;&lt; setw(wid) &lt;&lt; str2 &lt;&lt; &quot; &quot;; top = analyStack.back(); cur = *ip; // 处理标识符和数字(转换为i/n) if (isalpha(cur)) cur = &#39;i&#39;; else if (isdigit(cur)) cur = &#39;n&#39;; // 栈顶是终结符或$ if (terminal.find(top) != string::npos || top == &#39;$&#39;) { if (top == cur) { analyStack.pop_back(); ++ip; fout &lt;&lt; endl; } else { fout &lt;&lt; &quot;出错! 不匹配,弹出&quot; &lt;&lt; top &lt;&lt; endl; analyStack.pop_back(); // 弹出不匹配的栈顶 } } // 栈顶是非终结符 else { try { int x = index[top]; int y = index[cur]; string production = table[x][y]; if (production.empty()) { fout &lt;&lt; &quot;出错!空白,跳过&quot; &lt;&lt; cur &lt;&lt; endl; ++ip; } else if (production == &quot;synch&quot;) { fout &lt;&lt; &quot;出错!synch,弹出&quot; &lt;&lt; top &lt;&lt; endl; analyStack.pop_back(); } else { analyStack.pop_back(); // 弹出非终结符 string expr = production.substr(3); // 提取右部(如&quot;TA&quot;) if (expr == &quot;e&quot;) expr = &quot;&quot;; // 空产生式处理 // 逆序压栈 for (int i = expr.size() - 1; i &gt;= 0; --i) { analyStack.push_back(expr[i]); } fout &lt;&lt; production &lt;&lt; endl; } } catch (out_of_range) { fout &lt;&lt; &quot;输入字符非法!&quot; &lt;&lt; endl; break; } } } while (top != &#39;$&#39;); // 当栈顶为$时结束循环(此时栈应为[&quot;$&quot;]) cout &lt;&lt; endl &lt;&lt; &quot;分析结果已输出至 fout.txt.&quot; &lt;&lt; endl; return 0; } 这段代码运行时报错:--------------------Configuration: zyg - Win32 Debug-------------------- Compiling... zyg.cpp C:\Users\JF02\Desktop\zyg.cpp(14) : error C2146: syntax error : missing &#39;,&#39; before identifier &#39;table&#39; C:\Users\JF02\Desktop\zyg.cpp(14) : error C2065: &#39;table&#39; : undeclared identifier C:\Users\JF02\Desktop\zyg.cpp(14) : error C2143: syntax error : missing &#39;&gt;&#39; before &#39;;&#39; C:\Users\JF02\Desktop\zyg.cpp(17) : error C2872: &#39;vector&#39; : ambiguous symbol C:\Users\JF02\Desktop\zyg.cpp(17) : error C2143: syntax error : missing &#39;;&#39; before &#39;&lt;&#39; C:\Users\JF02\Desktop\zyg.cpp(17) : error C2143: syntax error : missing &#39;;&#39; before &#39;&lt;&#39; C:\Users\JF02\Desktop\zyg.cpp(29) : error C2872: &#39;vector&#39; : ambiguous symbol C:\Users\JF02\Desktop\zyg.cpp(29) : error C2143: syntax error : missing &#39;;&#39; before &#39;&lt;&#39; C:\Users\JF02\Desktop\zyg.cpp(29) : error C2143: syntax error : missing &#39;;&#39; before &#39;&lt;&#39; C:\Users\JF02\Desktop\zyg.cpp(32) : error C2872: &#39;vector&#39; : ambiguous symbol C:\Users\JF02\Desktop\zyg.cpp(32) : error C2143: syntax error : missing &#39;;&#39; before &#39;&lt;&#39; C:\Users\JF02\Desktop\zyg.cpp(32) : error C2143: syntax error : missing &#39;;&#39; before &#39;&lt;&#39; C:\Users\JF02\Desktop\zyg.cpp(44) : error C2065: &#39;G&#39; : undeclared identifier C:\Users\JF02\Desktop\zyg.cpp(44) : error C2228: left of &#39;.push_back&#39; must have class/struct/union type C:\Users\JF02\Desktop\zyg.cpp(45) : error C2228: left of &#39;.push_back&#39; must have class/struct/union type C:\Users\JF02\Desktop\zyg.cpp(46) : error C2228: left of &#39;.push_back&#39; must have class/struct/union type C:\Users\JF02\Desktop\zyg.cpp(47) : error C2228: left of &#39;.push_back&#39; must have class/struct/union type C:\Users\JF02\Desktop\zyg.cpp(48) : error C2228: left of &#39;.push_back&#39; must have class/struct/union type C:\Users\JF02\Desktop\zyg.cpp(49) : error C2228: left of &#39;.push_back&#39; must have class/struct/union type C:\Users\JF02\Desktop\zyg.cpp(50) : error C2228: left of &#39;.push_back&#39; must have class/struct/union type C:\Users\JF02\Desktop\zyg.cpp(51) : error C2228: left of &#39;.push_back&#39; must have class/struct/union type C:\Users\JF02\Desktop\zyg.cpp(52) : error C2228: left of &#39;.push_back&#39; must have class/struct/union type C:\Users\JF02\Desktop\zyg.cpp(53) : error C2228: left of &#39;.push_back&#39; must have class/struct/union type C:\Users\JF02\Desktop\zyg.cpp(54) : error C2228: left of &#39;.push_back&#39; must have class/struct/union type C:\Users\JF02\Desktop\zyg.cpp(74) : error C2065: &#39;First&#39; : undeclared identifier C:\Users\JF02\Desktop\zyg.cpp(74) : error C2228: left of &#39;.push_back&#39; must have class/struct/union type C:\Users\JF02\Desktop\zyg.cpp(75) : error C2228: left of &#39;.push_back&#39; must have class/struct/union type C:\Users\JF02\Desktop\zyg.cpp(76) : error C2228: left of &#39;.push_back&#39; must have class/struct/union type C:\Users\JF02\Desktop\zyg.cpp(77) : error C2228: left of &#39;.push_back&#39; must have class/struct/union type C:\Users\JF02\Desktop\zyg.cpp(78) : error C2228: left of &#39;.push_back&#39; must have class/struct/union type C:\Users\JF02\Desktop\zyg.cpp(79) : error C2228: left of &#39;.push_back&#39; must have class/struct/union type C:\Users\JF02\Desktop\zyg.cpp(80) : error C2228: left of &#39;.push_back&#39; must have class/struct/union type C:\Users\JF02\Desktop\zyg.cpp(81) : error C2228: left of &#39;.push_back&#39; must have class/struct/union type C:\Users\JF02\Desktop\zyg.cpp(82) : error C2228: left of &#39;.push_back&#39; must have class/struct/union type C:\Users\JF02\Desktop\zyg.cpp(83) : error C2228: left of &#39;.push_back&#39; must have class/struct/union type C:\Users\JF02\Desktop\zyg.cpp(84) : error C2228: left of &#39;.push_back&#39; must have class/struct/union type C:\Users\JF02\Desktop\zyg.cpp(87) : error C2065: &#39;Follow&#39; : undeclared identifier C:\Users\JF02\Desktop\zyg.cpp(87) : error C2228: left of &#39;.push_back&#39; must have class/struct/union type C:\Users\JF02\Desktop\zyg.cpp(88) : error C2228: left of &#39;.push_back&#39; must have class/struct/union type C:\Users\JF02\Desktop\zyg.cpp(89) : error C2228: left of &#39;.push_back&#39; must have class/struct/union type C:\Users\JF02\Desktop\zyg.cpp(90) : error C2228: left of &#39;.push_back&#39; must have class/struct/union type C:\Users\JF02\Desktop\zyg.cpp(91) : error C2228: left of &#39;.push_back&#39; must have class/struct/union type C:\Users\JF02\Desktop\zyg.cpp(105) : error C2109: subscript requires array or pointer type C:\Users\JF02\Desktop\zyg.cpp(105) : error C2228: left of &#39;.size&#39; must have class/struct/union type C:\Users\JF02\Desktop\zyg.cpp(106) : error C2109: subscript requires array or pointer type C:\Users\JF02\Desktop\zyg.cpp(106) : error C2109: subscript requires array or pointer type C:\Users\JF02\Desktop\zyg.cpp(118) : error C2228: left of &#39;.size&#39; must have class/struct/union type C:\Users\JF02\Desktop\zyg.cpp(119) : error C2109: subscript requires array or pointer type C:\Users\JF02\Desktop\zyg.cpp(119) : error C2440: &#39;initializing&#39; : cannot convert from &#39;int&#39; to &#39;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;&#39; No constructor could take the source type, or constructor overload resolution was ambiguous C:\Users\JF02\Desktop\zyg.cpp(122) : error C2109: subscript requires array or pointer type C:\Users\JF02\Desktop\zyg.cpp(122) : error C2440: &#39;initializing&#39; : cannot convert from &#39;int&#39; to &#39;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;&#39; No constructor could take the source type, or constructor overload resolution was ambiguous C:\Users\JF02\Desktop\zyg.cpp(129) : error C2109: subscript requires array or pointer type C:\Users\JF02\Desktop\zyg.cpp(129) : error C2109: subscript requires array or pointer type C:\Users\JF02\Desktop\zyg.cpp(129) : error C2228: left of &#39;.empty&#39; must have class/struct/union type C:\Users\JF02\Desktop\zyg.cpp(130) : error C2109: subscript requires array or pointer type C:\Users\JF02\Desktop\zyg.cpp(130) : error C2109: subscript requires array or pointer type C:\Users\JF02\Desktop\zyg.cpp(130) : error C2440: &#39;=&#39; : cannot convert from &#39;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;&#39; to &#39;int&#39; No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called C:\Users\JF02\Desktop\zyg.cpp(133) : error C2109: subscript requires array or pointer type C:\Users\JF02\Desktop\zyg.cpp(133) : error C2440: &#39;initializing&#39; : cannot convert from &#39;int&#39; to &#39;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;&#39; No constructor could take the source type, or constructor overload resolution was ambiguous C:\Users\JF02\Desktop\zyg.cpp(137) : error C2109: subscript requires array or pointer type C:\Users\JF02\Desktop\zyg.cpp(137) : error C2109: subscript requires array or pointer type C:\Users\JF02\Desktop\zyg.cpp(137) : error C2228: left of &#39;.empty&#39; must have class/struct/union type C:\Users\JF02\Desktop\zyg.cpp(138) : error C2109: subscript requires array or pointer type C:\Users\JF02\Desktop\zyg.cpp(138) : error C2109: subscript requires array or pointer type C:\Users\JF02\Desktop\zyg.cpp(138) : error C2440: &#39;=&#39; : cannot convert from &#39;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;&#39; to &#39;int&#39; No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called C:\Users\JF02\Desktop\zyg.cpp(149) : error C2109: subscript requires array or pointer type C:\Users\JF02\Desktop\zyg.cpp(149) : error C2440: &#39;initializing&#39; : cannot convert from &#39;int&#39; to &#39;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;&#39; No constructor could take the source type, or constructor overload resolution was ambiguous C:\Users\JF02\Desktop\zyg.cpp(153) : error C2109: subscript requires array or pointer type C:\Users\JF02\Desktop\zyg.cpp(153) : error C2109: subscript requires array or pointer type C:\Users\JF02\Desktop\zyg.cpp(153) : error C2228: left of &#39;.empty&#39; must have class/struct/union type C:\Users\JF02\Desktop\zyg.cpp(154) : error C2109: subscript requires array or pointer type C:\Users\JF02\Desktop\zyg.cpp(154) : error C2109: subscript requires array or pointer type C:\Users\JF02\Desktop\zyg.cpp(154) : error C2440: &#39;=&#39; : cannot convert from &#39;char [6]&#39; to &#39;int&#39; This conversion requires a reinterpret_cast, a C-style cast or function-style cast C:\Users\JF02\Desktop\zyg.cpp(178) : error C2039: &#39;push_back&#39; : is not a member of &#39;basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;&#39; C:\Users\JF02\Desktop\zyg.cpp(180) : error C2872: &#39;vector&#39; : ambiguous symbol C:\Users\JF02\Desktop\zyg.cpp(180) : error C2143: syntax error : missing &#39;;&#39; before &#39;&lt;&#39; C:\Users\JF02\Desktop\zyg.cpp(180) : error C2143: syntax error : missing &#39;;&#39; before &#39;&lt;&#39; C:\Users\JF02\Desktop\zyg.cpp(181) : error C2065: &#39;analyStack&#39; : undeclared identifier C:\Users\JF02\Desktop\zyg.cpp(181) : error C2228: left of &#39;.push_back&#39; must have class/struct/union type C:\Users\JF02\Desktop\zyg.cpp(182) : error C2228: left of &#39;.push_back&#39; must have class/struct/union type C:\Users\JF02\Desktop\zyg.cpp(185) : error C2440: &#39;initializing&#39; : cannot convert from &#39;char *&#39; to &#39;int&#39; This conversion requires a reinterpret_cast, a C-style cast or function-style cast C:\Users\JF02\Desktop\zyg.cpp(191) : error C2228: left of &#39;.begin&#39; must have class/struct/union type C:\Users\JF02\Desktop\zyg.cpp(191) : error C2228: left of &#39;.end&#39; must have class/struct/union type C:\Users\JF02\Desktop\zyg.cpp(192) : error C2664: &#39;__thiscall std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;::std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;(const char *,unsigned int,const class std::allocator&lt;char&gt; &amp;)&#39; : cannot convert parameter 1 from &#39;int&#39; to &#39;const char *&#39; Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast C:\Users\JF02\Desktop\zyg.cpp(195) : error C2228: left of &#39;.back&#39; must have class/struct/union type C:\Users\JF02\Desktop\zyg.cpp(196) : error C2100: illegal indirection C:\Users\JF02\Desktop\zyg.cpp(205) : error C2228: left of &#39;.pop_back&#39; must have class/struct/union type C:\Users\JF02\Desktop\zyg.cpp(210) : error C2228: left of &#39;.pop_back&#39; must have class/struct/union type C:\Users\JF02\Desktop\zyg.cpp(218) : error C2109: subscript requires array or pointer type C:\Users\JF02\Desktop\zyg.cpp(218) : error C2109: subscript requires array or pointer type C:\Users\JF02\Desktop\zyg.cpp(218) : error C2440: &#39;initializing&#39; : cannot convert from &#39;int&#39; to &#39;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;&#39; No constructor could take the source type, or constructor overload resolution was ambiguous C:\Users\JF02\Desktop\zyg.cpp(225) : error C2228: left of &#39;.pop_back&#39; must have class/struct/union type C:\Users\JF02\Desktop\zyg.cpp(227) : error C2228: left of &#39;.pop_back&#39; must have class/struct/union type C:\Users\JF02\Desktop\zyg.cpp(233) : error C2228: left of &#39;.push_back&#39; must have class/struct/union type 执行 cl.exe 时出错. zyg.exe - 1 error(s), 0 warning(s) 根据报错修改上面代码
05-24
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值