??
1.函数模板初级,如果想使用模板,需要实例化,实例化的方式是加上数据类型>
#include
//函数模板可以对类型进行优化重载,根据类型会覆盖
//如果仍然要使用模板函数,需要实例化
templateclass
T>
T
add(T
a,
T
b)
{
std::cout
"T add " <<...
分类:
其他好文 时间:
2014-08-17 01:07:21
阅读次数:
292
转自:http://blog.csdn.net/daheiantian/article/details/6438782Code:#include using namespace std;class A {public:A() {cout<<"int A::A()"<<endl;}A(A &a) {c...
分类:
其他好文 时间:
2014-08-16 23:37:51
阅读次数:
248
3.1略3.2string str;//读行 while(getline(cin,str)) cout>str) cout>a>>b; if(a==b) coutb) cout>a>>b; if(a.size()==b.siz...
分类:
编程语言 时间:
2014-08-16 22:20:21
阅读次数:
375
C++输出中文字符1. cout场景1: 在源文件中定义 const char* str = "中文" 在 VC++ 编译器上,由于Windows环境用 GBK编码,所以字符串 "中文" 被保存为 GBK内码,编译器也把 str 指向一个包含有 GBK编码的只读内存空间.用 cout 输出 str ...
分类:
编程语言 时间:
2014-08-16 19:40:10
阅读次数:
667
C++继承和java中的差不多,下面举个简单示例:
main.cpp:
#include
#include "Box.h"
#include "Carton.h"
using std::cout;
using std::endl;
int main(){
Box myBox(40.0,30.0,20.0);
Carton myCarton;
Carton candy...
分类:
编程语言 时间:
2014-08-16 13:53:50
阅读次数:
266
animation:animation-name | animation-duration | animation-timing-function | animation-delay | animation-iteration-cout | animation-direction | a...
分类:
Web程序 时间:
2014-08-15 19:12:49
阅读次数:
237
【C-串比较的错误方式】不能直接比较char buffer1[6]="hello";char buffer2[6]="hello";cout#include//C-串操作的头文件using namespace std;int main(){ char* s1="hello "; char...
分类:
其他好文 时间:
2014-08-15 12:10:38
阅读次数:
136
头文件#include<>或#include""<>强制类型转换doublea=1.6;cout<<static_cast<int>(a)<<endl;输出为1注意旧的强制类型转换为int(a),这比新的更容易出错,得不到想要的结果,所以推荐static_cast<转换成的类型>()自动判断数据类型auton=16;..
分类:
其他好文 时间:
2014-08-15 02:54:27
阅读次数:
272
#include
using namespace std;
class B {
public:
void foo() { cout << "B foo " << endl; }
void pp() { cout << "B pp" << endl; }
void FunctionB() { cout << "funB" << endl; }
};
int main(...
分类:
其他好文 时间:
2014-08-14 14:17:38
阅读次数:
266
#includeusing namespace std;int main(){ int n; cin >> n; for (int i = 0; i > a >> b >> c; if (a>0 && a0 && b0 && cc&&a + c > b&&b + c > a) cout <<...
分类:
其他好文 时间:
2014-08-14 10:26:48
阅读次数:
186