Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» templet program
Constructos and Destructors assignment question:CD-3 EmptySun May 14, 2017 11:57 am by akarshsomani

» IP6: Write a C++ program that uses the concept of hybrid inheritance.
Constructos and Destructors assignment question:CD-3 EmptySun May 14, 2017 10:55 am by iamdsc_0410

» Overloading new and delete operator program
Constructos and Destructors assignment question:CD-3 EmptySat May 13, 2017 7:29 am by akarshsomani

» Constructos and Destructors assignment question:CD-3
Constructos and Destructors assignment question:CD-3 EmptyThu May 11, 2017 1:57 pm by Prateek Gupta

» Program related to Object Slicing : Why the output is not coming In Base a=2 ?
Constructos and Destructors assignment question:CD-3 EmptyFri May 05, 2017 7:36 am by akarshsomani

» Program given by sir i.e given in Reema Thareja on Overloading of new and delete operators is not working . Debug it !!
Constructos and Destructors assignment question:CD-3 EmptyMon May 01, 2017 9:11 am by iamdsc_0410

» constructor and destructor assignment solutions
Constructos and Destructors assignment question:CD-3 EmptyMon Apr 24, 2017 8:10 am by akarshsomani

» class and objects assignment solutions.
Constructos and Destructors assignment question:CD-3 EmptyFri Apr 21, 2017 9:01 pm by iamdsc_0410

» SMARKET SOLUTION
Constructos and Destructors assignment question:CD-3 EmptyTue Apr 18, 2017 6:33 pm by iamdsc_0410

Keywords

Who is online?
In total there is 1 user online :: 0 Registered, 0 Hidden and 1 Guest

None

[ View the whole list ]


Most users ever online was 7 on Tue Jun 02, 2020 6:34 am
RSS feeds


Yahoo! 
MSN 
AOL 
Netvibes 
Bloglines 


Constructos and Destructors assignment question:CD-3

Thu May 11, 2017 1:57 pm by Prateek Gupta

Code:
#include <bits/stdc++.h>

using namespace std;

class str
{
    char *s;
    int l;
    public:
    str()
    {
        s="/0";
    }
    str(int len)
    {
        l=len;
        s=new char[l];
    }
~str()
   {
        delete s;
        cout<<"Memory deallocated"<<endl;
   }
    void get()
    {
        cout<<"Enter the string:"<<endl;
        cin>>s;
    }
    void show()
    {
        cout<<"The string is: "<<s<<endl;
    }
    void reverse()
    {
        int i,c=0;
        char r[l];
        for(i=l-1;i>=0;i--)
            r[c++]=s[i];
        cout<<"The reverse string is:"<<r<<endl;
    }
};

int main()
{
    int l;
    cout<<"Enter the string length:"<<endl;
    cin>>l;
    str s(l);
    s.get();
    s.show();
    s.reverse();
    return 0;
}


Comments: 0

Social bookmarking

Social bookmarking reddit      

Bookmark and share the address of Coding Discussions on your social bookmarking website

March 2024
MonTueWedThuFriSatSun
    123
45678910
11121314151617
18192021222324
25262728293031

Calendar Calendar

Most active topic starters
akarshsomani
Constructos and Destructors assignment question:CD-3 Vote_lcapConstructos and Destructors assignment question:CD-3 Voting_barConstructos and Destructors assignment question:CD-3 Vote_rcap 
Prateek Gupta
Constructos and Destructors assignment question:CD-3 Vote_lcapConstructos and Destructors assignment question:CD-3 Voting_barConstructos and Destructors assignment question:CD-3 Vote_rcap 
iamdsc_0410
Constructos and Destructors assignment question:CD-3 Vote_lcapConstructos and Destructors assignment question:CD-3 Voting_barConstructos and Destructors assignment question:CD-3 Vote_rcap 
Arjun1810
Constructos and Destructors assignment question:CD-3 Vote_lcapConstructos and Destructors assignment question:CD-3 Voting_barConstructos and Destructors assignment question:CD-3 Vote_rcap 

Statistics
We have 10 registered users
The newest registered user is shivendra

Our users have posted a total of 44 messages in 19 subjects