Thread: Reverse() question?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    TransparentMember correlcj's Avatar
    Join Date
    Jun 2002
    Posts
    378

    Reverse() question?

    Code:
    #include<string.h>
    #include<iostream.h>
    
    const int max_len = 255;
    
    class string	{
    public:
    	void assign(const char* st)
    	{	strcpy(s, st); len = strlen(st);	}
    	int length() const	{ return len;	}
    	void print() const
    	{ cout << s << "\nLength: " << len << endl;}
    	
    private:
    	char s[max_len];
    	int len;
    	reverse();
    	};
    
    int main(void)
    {
    	string one, two;
    	char three[40] = {"My name is Charles."};
    
    	one.assign("My name is Alan.");
    	two.assign(three);
    	cout << three;
    	cout << "\nLength: " << strlen(three) << endl;
    	if (one.length() <= two.length())
    		one.print();
    	else
    		two.print();
    	return 0;
    }
    Why won't this reverse in the private member s?
    Last edited by correlcj; 08-05-2002 at 07:11 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. gethostbyaddr() reverse lookups failing (???)
    By Uncle Rico in forum C Programming
    Replies: 9
    Last Post: 08-19-2005, 09:22 AM
  2. I'm not ask for ENTIRE program, only 1 Question !
    By Th3-SeA in forum C Programming
    Replies: 10
    Last Post: 10-01-2003, 12:33 PM
  3. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  4. Replies: 7
    Last Post: 03-18-2003, 03:32 PM
  5. opengl DC question
    By SAMSAM in forum Game Programming
    Replies: 6
    Last Post: 02-26-2003, 09:22 PM