hello, c/c++

来源:互联网 发布:gtx970 gpuz数据 编辑:程序博客网 时间:2024/05/19 16:38
#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> ./aHello 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));  这种给指针赋值的方法很屌


原创粉丝点击