出于某种原因,我的代码在Visual Studio中工作,但在Linux编译器中没有,并且在Linux中给出了一个错误
test_main.cpp:65: error: no match for 'operator<<' in 'std::operator<<'
Run Code Online (Sandbox Code Playgroud)
在[]我的重载代码中有大量的行
String String::operator + (const String & s) const {
String temp;
temp.head = ListNode::concat(head,s.head);
return temp;
}
Run Code Online (Sandbox Code Playgroud)
我的concat代码
String::ListNode * String::ListNode::concat(ListNode * L1, ListNode * L2)
{
return L1 == NULL ? copy(L2): new ListNode(L1->info, concat(L1->next, L2));
}
Run Code Online (Sandbox Code Playgroud)
代码测试它
String firstString("First");
String secondString("Second");
cout << "+: " << firstString + secondString << endl;
Run Code Online (Sandbox Code Playgroud)
宣言
ostream & operator << (ostream & out, String & l);
Run Code Online (Sandbox Code Playgroud)
身体
ostream & operator << …Run Code Online (Sandbox Code Playgroud) 由于某种原因,我无法获得字符串数值转换为整数我运行的错误:
Exception in thread "main" java.lang.NumberFormatException: For input string: "6327818260"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:495)
at java.lang.Integer.parseInt(Integer.java:527)
at MyDirectory.getsize(MyDirectory.java:18)
at a19010.main(a19010.java:79)
Run Code Online (Sandbox Code Playgroud)
Java结果:1
如果我的输入字符串是"6327818260",为什么它不能成为整数?我的代码是
public String getsize()
{
int intSize = Integer.parseInt(mySize);
int count = 0;
String dataType = "";
while (intSize > 1000)
{
intSize = intSize / 1000;
count++;
}
switch (count)
{
case 0:
dataType = "Bytes";
break;
case 1:
dataType = "KB";
break;
case 2:
dataType = "MB";
break;
case 3:
dataType = "GB";
break;
case 4:
dataType …Run Code Online (Sandbox Code Playgroud)