What does this line mean or do in this example program

This is an example program from DS Malik textbook.
The program works 100% OK!!
But of interest to me is this line of code:
1
2
newString(int i0, int i1);
	//default constructor, custom range 

I do not know what that line means or is doing.
I commented it out of the program but the program still worked
OK without it.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
 //Header file newString.h
#ifndef H_newString
#define H_newString
#include <iostream>

using namespace std;

class newString
{
		//Overloads the stream insertion and extraction operators
    friend ostream& operator<<(ostream&, const newString&);
    friend istream& operator>>(istream&, newString&);

public:
    const newString& operator=(const newString&);
		 newString operator+(const newString& ) const;
    	newString(int i0, int i1);
	//default constructor, custom range
    newString(const char *);
		//constructor; conversion from the char string
    newString();
		//default constructor to initialize the string to null
    newString(const newString&);
		//copy constructor
    ~newString();
		//destructor

    char& operator[] (int);
    const char& operator[](int) const;

		//Overloads the relational operators
    bool operator==(const newString&) const;
    bool operator!=(const newString&) const;
    bool operator<=(const newString&) const;
    bool operator<(const newString&)  const;
    bool operator>=(const newString&) const;
    bool operator>(const newString&)  const;

private:
    char *strPtr;   //pointer to the char array
                    //that holds the string
    int strLength;  //data member to store the length
					//of the string
};
#endif 


Please assist!!!




It's a member function prototype for the constructor of the class. Just like all the other constructor prototypes that are there in that class.

You know how function prototypes work right? It's just like that but for the class. Those members are expected (though not guaranteed) to be redefined later on after the class declaration.

You probably know what constructors are because at least the program you posted thinks you do.
Last edited on
Topic archived. No new replies allowed.