class string {
  public:
    string( char const* t ) : s(t) {}
   ~string() { delete s; }
    char const* c_str() const { return s; }
  private:
    char const* s;
  };

there is a problem in the above code
can anyone help

Read this tutorial and you'll understand what the problem is with that code.

char const* should be const char*. May I ask why do you want to hold a constant string?

maybe he needs a const char* just to print it out. what else ?.... can we both agree that he should get back to basic oop and data types classroom again. just my opinion.

Just an observation...you do realize that a very useful and well defined string class already exists and you can include it in your program with #include <string> (if you want to use a string class...).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.