vc6.0简单使用
程序员文章站
2024-03-16 14:22:46
...
1.打开文件 新建项目(ctrl+N)
2.创建工作空间 工作项目 项目文件
#include <iostream>
using namespace std;
int main()
{
cout << "Hello, world!" << endl;
return 0;
}
#include <iostream>
using namespace std;
void func(int a=11,int b=22,int c=33)
{
cout <<"a="<<a<<",b="<<b<<",c="<<c<<endl;
}
int main()
{
func();
func(5);
func(77,99);
func(8,88,888);
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int oneInt=1;
int & ref=oneInt;
int const &refc=oneInt;// refc类型是可变的 不可以通过oneInt不改改变
//const int &refc=oneInt;//refc类型是不变的 可以通过oneInt改变
ref=2;
cout <<"oneInt="<<oneInt<<",ref="<<ref<<endl;
cout <<"refc="<<refc<<endl;
oneInt=3;
cout<<"ref="<<ref<<endl;
cout<<"refc="<<refc<<endl;
int &ref2=ref;
cout <<"ref2="<<ref2<<endl;
return 0;
}
#include <iostream>
#include <string>
using namespace std;
int main()
{
string str;
if(str.empty())
cout << "str is null."<<"lenghth="<<str.length()<<endl;
else
cout <<"str is not null."<<endl;
str=str.append("abcdefg");
cout << "str is "<<str<<",size="<<str.size()<<endl;
const char *p=str.c_str();//临时指针
cout<<"p="<<p<<endl;
cout<<"find:"<<str.find("de",0)<<endl;//3
cout<<"find:"<<str.find("de",4)<<endl;//查找失败 很大的数
string str1=str.insert(4,"123");
cout<<str1<<endl;
return 0;
}