Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
509 views

String Manipulation Using Operator Overloading - The Code Gallery

The document discusses C++ concepts like classes, objects, inheritance, polymorphism and operator overloading. It provides examples of overloading the + operator to concatenate two strings by defining a string class with relevant member functions like a default constructor, parameterized constructor and a display function. The example demonstrates how two string objects can be concatenated and displayed by overloading the + operator.

Uploaded by

nikunjpatel90
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
509 views

String Manipulation Using Operator Overloading - The Code Gallery

The document discusses C++ concepts like classes, objects, inheritance, polymorphism and operator overloading. It provides examples of overloading the + operator to concatenate two strings by defining a string class with relevant member functions like a default constructor, parameterized constructor and a display function. The example demonstrates how two string objects can be concatenated and displayed by overloading the + operator.

Uploaded by

nikunjpatel90
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

The Code Gallery

MENU

C++Tutorial

BasicConcepts

Introduction(index.php)
BasicTermsofOOP(BasicTerms.php)
InputOutputStatement(cin.php)
StructureofC++Program(structure.php)
DynamicInitialization(dynamicinit.php)
ReferenceVariable(RefVariable.php)

FunctioninC++

main()FunctioninC++(main.php)
FunctionPrototype(Prototype.php)
CallbyReference(CallByRef.php)
InlineFunction(Inline.php)
DefaultArgument(DefaultArg.php)
FunctionOverloading(FunctionOverloading.php)

ClassandObject
DefineClass(Class.php)
CreateObject(Object.php)
DefineMemberFunction(MemberFunction.php)
PrivateMemberFunction(PrivateFunction.php)
MemoryAllocation(Memory.php)
ArrayofObject(ArrayObject.php)
StaticDataMember(StaticMember.php)

StaticMemberFunction(StaticFunction.php)

PassObjectasArgument(PassObject.php)

FriendFunction(FriendFunction.php)

Constructor

Constructor(Constructor.php)
ParameterizedConstructor(ParamConst.php)
CopyConstructor(CopyConstructor.php)
ConstructorOverloading(ConstructorOverload.php)
Destructor(Destructor.php)

OperatorOverloading

OperatorOverloading(OperatorOverload.php)
OverloadUnaryOperator(UnaryOperator.php)
OverloadBinaryOperator(BinaryOperator.php)
StringManipulation(StringManipulation.php)

Inheritance

Inheritance(Inheritance.php)
DeriveClass(DeriveClass.php)
SingleInheritance(Single.php)
MultipleInheritance(Multiple.php)
MultilevelInheritance(Multilevel.php)
HierarchicalInheritance(Hierarchical.php)
HybridInheritance(Hybrid.php)
VirtualBaseClasses(VirtualBaseClass.php)

Polymorphism
Polymorphism(Polymorphism.php)
PointerstoObject(PointerObject.php)
thisPointer(thisPointer.php)
PointertoDerivedClass(PointerDerive.php)
VirtualFunction(VirtualFunction.php)

StringManipulationusingOperatorOverloading

C++allowsusthefacilityofmanipulatestringsusingtheconceptofoperatoroverloading.
Forexamplewecanoverload+operatortoconcatetwostrings.Wecanoverload==operatorto
comparetwostrings.
ConsiderFollowingExampleinwhichweoverload+operatortoconcatetwostrings.


Adsby Google Adsby Google Adsby Google

C++Download C++Code C++ClassJava

C++String C++Programming CC#C++

#include<iostream.h>
#include<string.h>
classstring
{
char*name
intlength
public:
string()
{
length=0
name=newchar[length+1]
}
string(char*n)
{
length=strlen(n)
name=newchar[length+1]
strcpy(name,n)
}
voiddisplay()
{
cout<<"String:"<<name
}
stringoperator+(strings)
{
stringtemp
strcpy(temp.name,name)
strcat(temp.name,s.name)
returntemp
}
}
intmain()
{
strings1("Hello")
strings2("Welcome")
strings3
s1.display()
s2.display()
s3=s1+s2
s3.display()
return0
}

DownloadProjects

DownloadPHP&MySQLProject(../PHP/Download.php)

DownloadVB.NETProjects(../VBNET/Download.php)

DownloadAndroidProjects(../Android/Download.php)
DownloadPrograms

DownloadCPrograms(../C/Download.php)

DownloadC++Programs(Download.php)

DownloadDataStructureProgram(../DSM/Program.php)

DownloadDataStructureAlgorithm(../DSM/Algorithm.php)
SitebuiltwithSimpleResponsiveTemplate(http://www.prowebdesign.ro/simpleresponsivetemplate/)

You might also like