过去几天我一直在"降级"> 1000个C++代码到C语言.直到现在一直很顺利.突然间我和一个班级面对面......
编译器首先在头文件中指出了错误:
class foobar {
foo mutex;
public:
foobar() {
oneCreate(&mutex, NULL);
}
~foobar() {
oneDestroy(mutex);
mutex = NULL;
}
void ObtainControl() {
oneAcquire(mutex);
}
void ReleaseControl() {
oneRelease(mutex);
}
};
Run Code Online (Sandbox Code Playgroud)
当然,C文件必须利用这一点
foobar fooey;
fooey.ObtainControl();
Run Code Online (Sandbox Code Playgroud)
我甚至不知道从哪里开始....帮助?
我有一个作业,我必须将类似c ++的程序转换为ac程序。
如果我有类似的东西
class B {
int var;
int somefunction(){
some code here
}
}
Run Code Online (Sandbox Code Playgroud)
它会变成
struct B{
int var;
}
int somefunction(){
some code here
}
Run Code Online (Sandbox Code Playgroud)
基本上,我不得不改变class,以struct每次看到它的时候,如果有一个功能,我现在把它移到了外面结构。
做这样的事情的最佳方法是什么?我得到了背后的理论,但不确定如何去实现它。