hello c++ pros,
iam a c++ beginner please help me with this code..iam unable to get the proper out put.In the above class i have tried to imitate String class and overloaded few operators. I got strucked up as show() method above was unable to print "t3" string properly.Please help me out.thanx in advance for the one who comes up with solution.
srinath3
-2
Newbie Poster
Recommended Answers
Jump to PostYou don't need to pass in another string to your show() method as you already have access to the one within the object. It should just be
cout <<p;
or you can#include <cstdio> and use puts()
P.S. When you are asking for help in the forums post it as …
Jump to PostI overlooked that show was a friend function and not a member but that's not where the error is.
In performing the + operation you need to return a reference to the calling object otherwise you're getting no result back so it's left with junk in the value on …
Jump to Postiam unable to get the appropriate out put for this code.I think the problem is with the operator overloading.Could any one come up with solution??
The main problem I can see is in your operator overload at line 17. The pointer 'temp' is uninitialised, it doesn't point to anything.
You …
Jump to PostJonsca PM'ed me and brought something to my attention that raises a very good point regarding this thread.
We've both recommended that the OP uses 'new' to create a new instance of the complex class in the operator+, but this would actually cause a memory leak as the memory …
All 16 Replies
jonsca
1,059
Quantitative Phrenologist
Team Colleague
Featured Poster
srinath3
-2
Newbie Poster
jonsca
1,059
Quantitative Phrenologist
Team Colleague
Featured Poster
srinath3
-2
Newbie Poster
srinath3
-2
Newbie Poster
jonsca
1,059
Quantitative Phrenologist
Team Colleague
Featured Poster
JasonHippy
739
Practically a Master Poster
jonsca
commented:
Above and beyond
+2
srinath3
-2
Newbie Poster
jonsca
1,059
Quantitative Phrenologist
Team Colleague
Featured Poster
srinath3
-2
Newbie Poster
srinath3
-2
Newbie Poster
jonsca
1,059
Quantitative Phrenologist
Team Colleague
Featured Poster
srinath3
-2
Newbie Poster
JasonHippy
739
Practically a Master Poster
srinath3
-2
Newbie Poster
WaltP
commented:
In English we add a SPACE after the '.' at the end of a sentence. Please use them.
-2
jonsca
1,059
Quantitative Phrenologist
Team Colleague
Featured Poster
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.