![编译错误]
无论我在相关行中做了什么改变,我都会一遍又一遍地得到这个恭维错误.如您所见,它将我发送到stl_iterator.h文件.
我不知道问题可能是什么.
有任何想法吗?
我在foreach声明中得到了这个错误.
foreach statement cannot operate on variables of type because does not contain a public definition for 'GetEnumerator'.
Run Code Online (Sandbox Code Playgroud)
它意味着什么,我怎么解决这个问题?
UPDATE
这是一些代码:
ServiceReference.TimereportResponseDto[] response;
foreach (ServiceReference.TimereportResponseDto r in response)
arbu.Text += r.Message + " " + r.Id + Environment.NewLine;
Run Code Online (Sandbox Code Playgroud)
添加[]到第一个精简版,现在我收到另一个错误:
Use of unassigned local variable 'response'
Run Code Online (Sandbox Code Playgroud)
更新2
我有这个文档示例,它看起来像这样:
Gateway.TimereportResponseDto[] response = theGate.CreateTimereport(timeReport);
foreach (Gateway.TimereportResponseDto r in response)
textBoxLog.Text += r.Message + " " + r.Id + Environment.NewLine;
Run Code Online (Sandbox Code Playgroud) 这段代码有什么问题?:当我声明私有类Listener实现ActionListener时,IDE只将Listener标记为红色,并说它不是抽象的
package hello;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class hello{
private JFrame mainFrame;
private JLabel title;
private JPanel mainPanel;
public hello(){
prepareGUI();
}
public static void main(String[] args){
hello helloo = new hello();
helloo.Event();
}
private void prepareGUI(){
mainFrame = new JFrame("This is a test project");
mainFrame.setSize(500, 500);
mainFrame.setLayout(new GridLayout(3,1));
mainPanel = new JPanel();
mainPanel.setLayout(new FlowLayout());
title = new JLabel("",JLabel.CENTER);
mainFrame.add(mainPanel);
mainFrame.add(title);
mainFrame.setVisible(true);
}
private void Event(){
JButton button1 = new JButton("Test");
button1.setSize(15,10);
button1.setActionCommand("Test");
button1.addActionListener(new Listener()); …Run Code Online (Sandbox Code Playgroud) 我自己正在编写 C++ 整数数组类和一个用于提取子数组的函数,但是在尝试编译我的代码时出现此错误:
“这一行有多个标记 - 没有返回,在函数中返回非空 - 带有 'Array Array::subArr(int, int)'”
(抱歉忘记包含此错误)
- ‘int* Array::subArr(int, int)’ cannot be overloaded
Run Code Online (Sandbox Code Playgroud)
但是为什么不能超载呢?
Array 类的私有数据成员是:
private:
int *arr;
int *subArray;
int *subArr1;
int len;
Run Code Online (Sandbox Code Playgroud)
导致错误的两个公共函数是:
int * subArr(int pos, int siz)
{
if (pos+siz < len)
{
subArr1 = new int[siz];
for (int i=0; i<siz; i++)
{
subArr1[i] = arr[pos];
pos++;
}
return subArr1;
}
}
Run Code Online (Sandbox Code Playgroud)
和
Array subArr(int pos, int siz)
{
if (arr != NULL && (siz + pos) < len) …Run Code Online (Sandbox Code Playgroud) 当我尝试编译我的C程序时,终端告诉我:
warning: implicit declaration of function 'strcopy' is
invalid in C99 [-Wimplicit-function-declaration]strcopy("test","test");
我#include <string.h>在代码的顶部,所以我很困惑为什么它不会编译.任何帮助,将不胜感激
我有这个代码:
FILE *f = fopen(intPath, "r");
Node *n;
if (f) {
try {
n = parse(f, intPath);
} catch (SyntaxError e) {
fclose(f); /***** line 536 *****/
throw LangException(
builtin_classes::exception_class::create_ImportError(
String::fromAscii(e.filename)->
append(String::fromAscii(":"))->
append(String::fromInt(e.line))->
append(String::fromAscii(":"))->
append(String::fromInt(e.col))->
append(String::fromAscii(": syntax error: "))->
append(String::fromAscii(e.message))
);
}
fclose(f);
return n->eval(scope);
} else {
throw LangException(
builtin_classes::exception_class::create_ImportError(
String::fromAscii("failed to open file for reading")
),
line,
col
);
}
Run Code Online (Sandbox Code Playgroud)
编译器给出了这个错误:
nodes.cpp:537:40:错误:在
‘(’token
nodes.cpp 之前的预期primary-expression :544:94:错误:令牌‘)’之前的预期‘;’
我不知道它可能是什么,特别是因为该代码示例具有另一个执行相同操作的语句,并且它不会导致错误.
当我在C#中链接表单时,我总是遇到这个问题.这是第一种形式的代码:
using ybird;
public partial class form1 : Form
{
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
try
{
register form = new register();
register.Show();
}
catch (Exception w)
{
MessageBox.Show(w.Message, Application.ProductName);
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是Register.cs的代码:
namespace ybird
{
public partial class register : Form
{
}
}
Run Code Online (Sandbox Code Playgroud)
我做错了什么?
C:\Program Files (x86)\Microsoft Visual C++ Build Tools>pip install pyaudio
Collecting pyaudio
Using cached PyAudio-0.2.11.tar.gz
Installing collected packages: pyaudio
Running setup.py install for pyaudio ... error
Complete output from command c:\python27\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\cybercry\\AppData\\Local\\Temp\\pip-build-tder68r3\\pyaudio\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\cybercry\AppData\Local\Temp\pip-0p059g11-record\install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.7
copying src\pyaudio.py -> build\lib.win-amd64-3.7
running build_ext
building '_portaudio' extension
creating build\temp.win-amd64-3.7
creating build\temp.win-amd64-3.7\Release
creating build\temp.win-amd64-3.7\Release\src
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 …Run Code Online (Sandbox Code Playgroud) 即使我收到一个警告,一个函数从局部变量返回一个地址,它也会编译。那不是编译器的UB吗?生成的程序集:
.text
.LC0:
.asciz "%i\n"
.globl foo
.type foo, @function
foo:
pushq %rbp #
movq %rsp, %rbp #,
sub $16, %rsp #,
mov %rdi, -8(%rbp) #,
leaq -8(%rbp), %rax #,
# a.c:5: }
leave
ret
.size foo, .-foo
.globl main
.type main, @function
main:
pushq %rbp #
movq %rsp, %rbp #,
# a.c:8: foo();
movl $123, %edi #,
call foo #
movq (%rax), %rsi #,
leaq .LC0(%rip), %rdi #,
movl $0, %eax #,
call printf #,
movl $0, …Run Code Online (Sandbox Code Playgroud) 全部!我在扫描仪/传递文本文件作为方法的参数时遇到问题。如果我在 main 中创建一个 Scanner,我就可以做所有事情。
import java.io.*;
import java.util.ArrayList;
import java.util.Scanner;
public class App {
public static void main(String[] args){
File file = new File([FILEPATH]);
Scanner inputFile = new Scanner(file);
...
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试将文本文件传递给方法并在那里创建扫描仪时,我收到 FileNotFoundException
import java.io.*;
import java.util.ArrayList;
import java.util.Scanner;
public class App {
public static void main(String[] args){
File file = new File([FILEPATH]);
method(file);
}
public static String method(File file){
Scanner inputFile = new Scanner(file); //This is where I get the error :(
...
Run Code Online (Sandbox Code Playgroud)
问题的提示特意说参数必须是文件,所以我不能改成String参数来传递文件路径。
我使用 .getPath() 来确保我的方法中文件的文件路径与 main 中文件的文件路径匹配,而且确实如此。我不确定需要修复什么。非常感谢任何帮助!
编辑; …
compiler-errors ×10
c++ ×3
c ×2
c# ×2
java ×2
.net ×1
assembly ×1
class ×1
foreach ×1
installation ×1
java-io ×1
namespaces ×1
object ×1
pip ×1
python ×1
python-2.7 ×1
swing ×1
x86 ×1