#include <stdio.h>
#include <string>
#include <iostream>
std::string Hello()
{
char buf[32] = "Hello Tyson.";
return buf;
}
char* Hello1()
{
char buf[32] = "Hello Tyson.";
return buf;
}
int main()
{
std::cout << Hello() << std::endl;
std::cout << Hello1() << std::endl;
return 0;
}
selnx176:exufhua__ndpgsn_5_0_wb__ndpgsn_5_0_atm532_1:~/hxfan/lib/linux/net> ./a
Hello Tyson. üp·
Hello()能正常工作, 原因是 std::string 产生临时变量
&ptr->_val 正常工作, 原因是->比&优先级高
STL algorithm:
find, find_if
gcc中
-DGPBV4 即宏变量GPBV4赋值默认为1
-DCPU=GPBV4 那么宏变量CPU现在的值为1
A* a(new A(5)); 这种给指针赋值的方法很屌