这是怎么回事
本帖最后由 SHARK_8 于 2018-4-1 09:36 编辑#include <iostream>
void print();
namespace jill
{
int fetch = 1000;
};
int main ()
{
jill::fetch = 500;
std::cout << jill::fetch << std::endl;
print;
std::cout << jill::fetch << std::endl;
return 0;
}
void print()
{
jill::fetch = 6000000;
std::cout << jill::fetch ;
std::cout << "haha" ;
}
输出结果为
500
500
函数根本不执行?? 调用的时候后面要跟括号 楼上正解:
#include <iostream>
void print();
namespace jill
{
int fetch = 1000;
};
int main ()
{
jill::fetch = 500;
std::cout << jill::fetch << std::endl;
print();
std::cout << jill::fetch << std::endl;
return 0;
}
void print()
{
jill::fetch = 6000000;
std::cout << jill::fetch ;
std::cout << "haha" ;
}
页:
[1]