我尝试通过"简单地"计算圆圈来学习使用函数中的指针.我得到错误,expected expression before '=' token
但无法理解为什么.说...之前的预期表达对我来说不清楚,是什么样的?
#define PI = 3.1415f
void circle(float *wert) {
*wert = ( (*wert) * (*wert) * PI );
}
int main(void) {
float radius;
printf("radius input: ");
scanf("%f", &radius);
circle(&radius);
printf("the circle size will be: %f", &radius);
}
Run Code Online (Sandbox Code Playgroud) 我尝试在一个单独的类中添加JPanels来单独调用它们并在其上添加不同的项目.请你告诉我我做错了什么?
MyFrame.java
import javax.swing.*;
import java.awt.*;
public class MyFrame extends JFrame {
public static void main(String[] args) {
MyFrame frame = new MyFrame();
frame.setVisible(true);
}
public MyFrame() {
setTitle("MyFrame");
setSize(300, 200);
setLocationRelativeTo(null);
setDefaultCloseOperation(EXIT_ON_CLOSE);
MyPanel panel = new MyPanel();
JButton testButton = new JButton("Test");
panel.add(testButton);
}
}
Run Code Online (Sandbox Code Playgroud)
MyPanel.java
import javax.swing.*;
import java.awt.*;
class MyPanel extends JPanel {
public MyPanel() {
this.setOpaque(true);
this.setVisible(true);
}
}
Run Code Online (Sandbox Code Playgroud)