我做了一个简单的程序测试指针、引用和递归。
这是要忽略的代码(抱怨问题来自 PassAddresses 的函数):
#include <iostream>
using namespace std;
long RecRecur(short &caps);
void PassAddresses(short &address, short &address2, const char *nosey);
int main(int args, char **LOC)
{
short test = 15;
const char rosey = 0;
short myLick = 500;
short PersonalWhim = 250;
const char *LOG = &rosey;
RecRecur(test);
PassAddresses(myLick, PersonalWhim, LOG);
}
void PassAddresses(short &address, short &address2, const char *nosey)
{
address = address + address;
address2 += address;
for(short i = 100; i < 1000; i++)
{
for(short c = 50; c != 120; c++)
{
cout << "These are just for-loop tests...." << /n;
}
}
cout << address << /n << address2 << /n << nosey << /n << &rosey;
}
long RecRecur(short &caps)
{
caps--;
if(caps > 0x7CDE)
{
RecRecur();
}
else return;
}
基本上编译器抱怨在“/”字符之前需要一个“主表达式”,我对问题可能是什么一无所知。“地址”值上的表达式/运算符是完全可以互换的。