1、static example* greateobject(int xp) 这句是什么意思?
通过值传递xp,创建一个example实例,返回指向这个实例的指针。
2、static void deleteobject(example*pe) //这个函数与上面一个函数相比为什么这边在void后面没有example?????
没有example是因为这个函数只是用来删除pe指向的example的实例,无需返回一个example类的实例指针,删除了还指向谁啊,对吧。
3、example *pexample=example::greateobject(5); //这句是什么意思?
通过上面的静态方法值传递(5)来创建example的实例,并且用指针p来指向这个实例,以便以后使用它。
4、example::deleteobject(pexample);这句是什么意思?
使用完自己创建的实例后,通过自己定义的静态的删除实例的方法,由于上面实例是自己动态申请的,所以这里自己再删除它,是分内之事了哈。
另外,团IDC网上有许多产品团购,便宜有口碑
这里利用了指针和字符串,指针指向字符串的地址。p++是p=p+1赋值语句
运行下面这个小程序,应该可以明白其中的道理
#include
#include
using namespace std;
int main()
{
string str[2]={"abgrr","test"};
string *p=&str[0];
cout<<*p<
cout<<*p<
}
p++之后会出错的。 cout< return 0;
#include
#include
using namespace std;
int main()
{
string str="abgrr";
string p=str;
cout<
}
呵呵,注意这是string 类型,不是char类型