class 1
介绍了一些学习编程的事情,虽然没有具体的讲某种语言,但是还是很有用,能达到一些共鸣
C++的安全性比Java略差,是因为创造C++的人希望程序员是自由的,因为很多时候如果要确保每个地方都没有错误,会同时增加处理问题的时间。
C++本身并不具备图形系统,这就意味着windows mac 都有自己不同的图形库,这和java不同
class 2
介绍C++和java语法上的区别,不会java,所以没有细看
class 3
string s="hello"; for(int i=0;i<s.length();i++) s[i]=toupper(s[i]); cout<<s<<endl; return 0;
这是一段很常见的string的使用,可是要注意到是用字符串面值给string赋值的
来看一下string类的构造函数
inline String::String(const char* str) { if (!str) m_data=0; else { m_data = new char[strlen(str)+1]; strcpy(m_data,str); } }
应该调用的是这个构造函数,注意到里面使用的是strcpy函数
char *strcpy(char *strDestination,const char *strSource) { assert(strDestination!=NULL && strSource!=NULL); char *strD=strDestination; while ((*strD++=*strSource++)!='\0'); return strDestination; }
它其实是一个复制的过程,这就将不可以改变的字符串面值转化为了可以改变的string