我有以下代码在LinkedList中插入一个元素。我已经按照教程,我无法在此代码中发现错误。
我正在使用DEVC ++,它给我一个编译时错误,上面写着: [错误]' Node'未申报(首次使用此功能)
import com.sun.prism.shader.DrawCircle_Color_Loader;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
public class drawing extends JFrame implements MouseListener{
private int r = 255, g = 0, b = 0;
private JSlider colorSlider, redSlider,greenSlider,blueSlider;
private JLabel colorLabel,redLabel,greenLabel,blueLabel;
private int x = 50;
private int y = 50;
public drawing(){
JFrame frame = new JFrame("Drawing App");
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setSize(800,800);
Container contentPane = frame.getContentPane();
JMenuBar mb = new JMenuBar();
frame.setJMenuBar(mb);
JMenu color = new JMenu("Colour");
JMenu size = new JMenu("Size");
mb.add(color);
mb.add(size);
JMenuItem colorRed = new JMenuItem("Red");
JMenuItem colorBlue = new JMenuItem("Blue");
JMenuItem colorGreen = new JMenuItem("Green");
color.add(colorBlue);
color.add(colorGreen);
color.add(colorRed);
JMenuItem one = new JMenuItem("1");
JMenuItem two = new JMenuItem("2");
JMenuItem three = new JMenuItem("3");
JMenuItem four = new JMenuItem("4");
JMenuItem five = new JMenuItem("5");
size.add(one);
size.add(two);
size.add(three);
size.add(four);
JPanel panel = new JPanel();
setBackground(Color.WHITE);
contentPane.add(panel,BorderLayout.NORTH);
JPanel panel1 = new JPanel();
contentPane.add(panel1,BorderLayout.SOUTH);
JPanel panel2 = new JPanel();
contentPane.add(panel2,BorderLayout.EAST);
panel1.setLayout(new GridLayout(0,1));
JColorChooser colors = new JColorChooser();
panel1.add(colors);
frame.setVisible(true);
panel.add(panel);
}
public void paint(Graphics g)
{
g.setColor(Color.red);
g.fillOval(x,y,100,100);
}
public void mousePressed(MouseEvent e) {}
public void mouseReleased(MouseEvent e) {}
public void mouseEntered(MouseEvent e) {}
public void mouseExited(MouseEvent e) {}
public void mouseClicked(MouseEvent e) {
x = e.getX();
y = e.getY();
repaint();
}
public static void main(String[] args) {
drawing Drawing = new drawing();
}
答案 0 :(得分:1)
将Node* temp= (Node*)malloc(sizeof(struct Node))
更改为struct Node* temp = (struct Node*)malloc(sizeof(struct Node))
答案 1 :(得分:-1)
创建一个更模块化的链接列表库...你的程序可读性更低。而且在使用c..t中的结构时,尽可能多地使用typedef,这将使你有更多权利使用NODE *而不是struct NODE * every时间...