Help with this program
-
hey guys, i'm pretty new to C++ and have a program i'm trying to write. i basically have the .h file done except for the private data members. the project instructions are below as well as what i have of the .h file. i'm sure you guys probably think this is easy but if anyone can do it so atleast i have something to refer to i'd aprecitae it. thanks Your job is to implement and test this ADT using an array allocated with the new operator in the constructors and de-allocated with the delete [] operator in the destructor. You will find that three data members will be sufficient for the job. At a minimum, you must test each function with enough different arguments to show it works. You are allowed to define additional helper functions, member functions or otherwise //--------------------------------------------------------------------------- #ifndef MyStringH #define MyStringH //--------------------------------------------------------------------------- typedef char CharType; // Allow for other character types class String { public: // Constructors and Destructor String( int capacity = 50 ); // Make empty String with given capacity String( const String & str ); // Copy str String( const CharType * str, int capacity = 50 ); // Make str a String ~String(); // Queries unsigned Length() const { return count_; } bool IsEmpty() const { return (count_ == 0); } bool IsFull() const { return count_ == capacity_; } int IndexOf( const String & str ); String SubString( unsigned start, unsigned count ) const; // Copy out const CharType * c_str() const; // Modifiers CharType & operator[]( int index ) { return string_[index]; } // Unsafe bool Delete( unsigned start, unsigned count ); bool Insert( unsigned pos, const String & str ); private: I NEED THE PRIVATE DATA MEMBERS FOR HERE }; //--------------------------------------------------------------------------- #endif thanks again :)
-
hey guys, i'm pretty new to C++ and have a program i'm trying to write. i basically have the .h file done except for the private data members. the project instructions are below as well as what i have of the .h file. i'm sure you guys probably think this is easy but if anyone can do it so atleast i have something to refer to i'd aprecitae it. thanks Your job is to implement and test this ADT using an array allocated with the new operator in the constructors and de-allocated with the delete [] operator in the destructor. You will find that three data members will be sufficient for the job. At a minimum, you must test each function with enough different arguments to show it works. You are allowed to define additional helper functions, member functions or otherwise //--------------------------------------------------------------------------- #ifndef MyStringH #define MyStringH //--------------------------------------------------------------------------- typedef char CharType; // Allow for other character types class String { public: // Constructors and Destructor String( int capacity = 50 ); // Make empty String with given capacity String( const String & str ); // Copy str String( const CharType * str, int capacity = 50 ); // Make str a String ~String(); // Queries unsigned Length() const { return count_; } bool IsEmpty() const { return (count_ == 0); } bool IsFull() const { return count_ == capacity_; } int IndexOf( const String & str ); String SubString( unsigned start, unsigned count ) const; // Copy out const CharType * c_str() const; // Modifiers CharType & operator[]( int index ) { return string_[index]; } // Unsafe bool Delete( unsigned start, unsigned count ); bool Insert( unsigned pos, const String & str ); private: I NEED THE PRIVATE DATA MEMBERS FOR HERE }; //--------------------------------------------------------------------------- #endif thanks again :)
Will Try to help you out. :doh: Luckyhuss
-
hey guys, i'm pretty new to C++ and have a program i'm trying to write. i basically have the .h file done except for the private data members. the project instructions are below as well as what i have of the .h file. i'm sure you guys probably think this is easy but if anyone can do it so atleast i have something to refer to i'd aprecitae it. thanks Your job is to implement and test this ADT using an array allocated with the new operator in the constructors and de-allocated with the delete [] operator in the destructor. You will find that three data members will be sufficient for the job. At a minimum, you must test each function with enough different arguments to show it works. You are allowed to define additional helper functions, member functions or otherwise //--------------------------------------------------------------------------- #ifndef MyStringH #define MyStringH //--------------------------------------------------------------------------- typedef char CharType; // Allow for other character types class String { public: // Constructors and Destructor String( int capacity = 50 ); // Make empty String with given capacity String( const String & str ); // Copy str String( const CharType * str, int capacity = 50 ); // Make str a String ~String(); // Queries unsigned Length() const { return count_; } bool IsEmpty() const { return (count_ == 0); } bool IsFull() const { return count_ == capacity_; } int IndexOf( const String & str ); String SubString( unsigned start, unsigned count ) const; // Copy out const CharType * c_str() const; // Modifiers CharType & operator[]( int index ) { return string_[index]; } // Unsafe bool Delete( unsigned start, unsigned count ); bool Insert( unsigned pos, const String & str ); private: I NEED THE PRIVATE DATA MEMBERS FOR HERE }; //--------------------------------------------------------------------------- #endif thanks again :)
-
hey guys, i'm pretty new to C++ and have a program i'm trying to write. i basically have the .h file done except for the private data members. the project instructions are below as well as what i have of the .h file. i'm sure you guys probably think this is easy but if anyone can do it so atleast i have something to refer to i'd aprecitae it. thanks Your job is to implement and test this ADT using an array allocated with the new operator in the constructors and de-allocated with the delete [] operator in the destructor. You will find that three data members will be sufficient for the job. At a minimum, you must test each function with enough different arguments to show it works. You are allowed to define additional helper functions, member functions or otherwise //--------------------------------------------------------------------------- #ifndef MyStringH #define MyStringH //--------------------------------------------------------------------------- typedef char CharType; // Allow for other character types class String { public: // Constructors and Destructor String( int capacity = 50 ); // Make empty String with given capacity String( const String & str ); // Copy str String( const CharType * str, int capacity = 50 ); // Make str a String ~String(); // Queries unsigned Length() const { return count_; } bool IsEmpty() const { return (count_ == 0); } bool IsFull() const { return count_ == capacity_; } int IndexOf( const String & str ); String SubString( unsigned start, unsigned count ) const; // Copy out const CharType * c_str() const; // Modifiers CharType & operator[]( int index ) { return string_[index]; } // Unsafe bool Delete( unsigned start, unsigned count ); bool Insert( unsigned pos, const String & str ); private: I NEED THE PRIVATE DATA MEMBERS FOR HERE }; //--------------------------------------------------------------------------- #endif thanks again :)