-6

The c++ code I am unable to understand the pointer inside the class. What does this line char *txtTemp = NULL represents?

#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; 
}
meJustAndrew
  • 6,011
  • 8
  • 50
  • 76
ram4279
  • 31
  • 3

1 Answers1

0

It's a default argument, so you can call BixString() with no arguments, and the txtTemp variable will be NULL.

Colin
  • 3,394
  • 1
  • 21
  • 29