jeudi 1 octobre 2015

Error in initialising constructor

Design and code a class named Text that manages a dynamically allocated array of strings. Upon instantiation, aText object receives nothing or a reference to an unmodifiable string. The string holds the name of the text file that contains the records to be stored in an object of this class. If the file does not exist, the Text object assumes a safe empty state. If the file exists, the one-argument constructor allocates memory for the number of records contained in the file and copies them into memory. To review the syntax for reading from a text file using an ifstream object see the chapter in your OOP244 notes entitled Custom File Operators. See also cplusplus.com

Your design also includes the following member functions:

  • a copy constructor
  • a copy assignment operator
  • a move constructor
  • a move assignment operator
  • a destructor
  • a member function named size_t size() const that returns the number of records of text data

Define your class and its implementation in namespace w3.

Following is my Text.h:

//Text.h
namespace w3{
        class Text{
                        std::string *name;
                public:
                        Text();
                        Text(char* file);
                        Text(const Text&); //copy constructor
                        Text(Text&&); //move constructor
                        Text& operator=(const Text&); //copy assignment operator
                        Text&& opeartor=(Text&&); //move assignment operator
                        ~Text();
                        size_t size() const;
};
}

I dont know if i am going right or not. Am having problem with the one-argument constructor.

Aucun commentaire:

Enregistrer un commentaire