我需要将一个程序从C++转换为C,即我需要相同的程序,但在C中.
我在C++中使用了成员函数,但我只知道基本的C级.
我知道这可以用结构来完成,但是怎么做我在C中实现了Structure的类函数?
这是代码.这是一个简单的程序,可以存入银行账户,存款,取款或显示账户状态:
#include<iostream>
#include<string.h>
int count = 0;
using namespace std;
class bank
{
public:
long bal, dep, wdamt;
int acno;
char name[20], type;
public:
void set(int x, char n[20], char t)
{
acno = x;
strcpy(name, n);
type = t;
bal = 0;
}
void deposit(long z)
{
bal += z;
cout << "success!";
}
void withdraw(long k)
{
bal -= k;
cout << "success!";
}
void display()
{
cout << "\n Name : " << name …Run Code Online (Sandbox Code Playgroud) 我想将文本字段添加a01, a02, ...到数组中a.我想显示值,val以便我知道文本是从文本字段中获取的.此代码不显示任何错误,但是,它也不会给我输出.
int i, j;
JTextField[][] a = new JTextField[9][9];
int[][] val = new int[9][9];
for (i = 0; i < 9; i++)
{
for (j = 0; j < 9; j++)
{
val[i][j] = Integer.parseInt(a[i][j].getText());
System.out.println(val[i][j]);
}
}
Run Code Online (Sandbox Code Playgroud)
这是我在这里提出的问题.