【发布时间】:2017-12-16 21:45:28
【问题描述】:
c++ 代码
我无法理解类内的指针。
char *txtTemp = NULL 这一行代表什么?
#include<iostream.h>
#include<string.h>
#include<malloc.h>
class BixString
{
char txtName[20];
public:
BixString(char *txtTemp = NULL)
{
if(txtTemp != NULL)
strcpy(txtName, txtTemp);
}
void Display(void)
{
cout<<txtName;
}
};
int main()
{
char *txtName = (char*)malloc(10);
strcpy(txtName, "IndiaBIX");
*txtName = 48;
BixString objTemp(txtName);
cout<< sizeof(txtName);
return 0;
}
【问题讨论】:
-
我建议您获取a good book 并阅读一下。