In line 14 of specification file there are two parameters (pointers to char). the thing i have learned so far is that pointers store address of a variable by & operator but in the int main function on line # 8 direct strings are passed. is it correct to pass direct strings to pointer variable?
1 // Specification file for the Contact class.    
2 #ifndef CONTACTINFO_H    
3 #define CONTACTINFO_H    
4 #include <cstring> // Needed for strlen and strcpy    
5    
6 // ContactInfo class declaration.    
7 class ContactInfo    
8 {    
9 private:    
10 char *name; // The name    
11 char *phone; // The phone number    
12 public:    
13 // Constructor    
14 ContactInfo(char *n, char *p)    
15 { // Allocate just enough memory for the name and phone number.    
16 name = new char[strlen(n) + 1];    
17 phone = new char[strlen(p) + 1];    
18    
19 // Copy the name and phone number to the allocated memory.    
20 strcpy(name, n);    
21 strcpy(phone, p);     
22}    
23 // Destructor    
24 ~ContactInfo()    
25 { delete [] name;    
26 delete [] phone;     
27}    
28 const char *getName() const    
29 { return name; }    
30 const char *getPhoneNumber() const    
31 { return phone; }    
32 };    
33 #endif    
// main     
1 #include <iostream>    
2 #include "ContactInfo.h"    
3 using namespace std;    
4 int main()    
5 {    
6 // Define a ContactInfo object with the following data:    
7 // Name: Kristen Lee Phone Number: 555-2021    
8 ContactInfo entry("Kristen Lee", "555-2021");    
9    
10 // Display the object's data.    
11 cout << "Name: " << entry.getName() << endl;    
12 cout << "Phone Number: " << entry.getPhoneNumber() << endl;    
13 return 0;    
14 }
 
     
    