#include "stdafx.h"
#include<iostream>
#include<conio.h>
using namespace std;
class Add{
public:
char *rep;
Add(){}
Add(char *tem){
rep = new char[strlen(tem)+1] ;
strcpy(rep,tem);
}
Add operator + (const Add &rhs)
{
char *temp;
temp= new char[strlen(rep) + strlen(rhs.rep)+1];
temp = strcat(rep,rhs.rep);
return Add(temp);
}
};
int main()
{
cout<<"hello";
Add obj1("pradeep");
Add obj2("bansal");
Add obj3;
obj3 = obj1+obj2;
cout<<obj3.rep;
getch();
return 0;
}
== == === === === === === === Some Body told me that operator overloading is not there because it violates the transparency of java.since there is no hiding of information in java it does support op overloading === === === === === === Pranab Kumar Rana Software Engineer..... === === === ===
a write the algorithm to concatenate two given string
There are 5 operators which cannot be overloaded. They are: * .* - class member access operator * :: - scope resolution operator * . - dot operator * ?:: - conditional operator * Sizeof() - operator Note:- This is possible only in C++.
I will not use operator overloading in C# to do anything. Operator overloading may lead to one operator has more than 1 semantic meaning. For example, we know 1 + 2 yields 3, and "1" + 2 yields "12". I do not like this overloading of the operator + being used for addition in Number hierarchy, while as the concatenation in strings. That is, one operator (+) has 2 significant semantics.And the question "find largest of two object" is too vague - what do you mean "largest"? and object? We know apple and orange are 2 objects, but how do you compare them, and find the largest one?????? (size, price or what???)
I think you mean operation overlord??? It is the American, Canadian and British offensive on Europe in World War 2. They landed in Normandy on 6th June 1944 (Commonly called D-Day, Day of Days or Deliverance Day) and progressed throughout France liberating Paris on the 25th August. This allowed the allies a foothold in Europe.
C does not support operator overloading. If you mean C++ operator overloading, it depends on exactly what you wanted to do. If you wanted to '+' to strings, then you could write: string operator+(string a, string b) { // do something }
Same operator can be used for different purposes like + can be used for addition of two integers and used for concatenate strings.
Java does not support user defined operator overloading.The operator '+' is overloaded in Java and can be used for adding both numbers and Strings.
== == === === === === === === Some Body told me that operator overloading is not there because it violates the transparency of java.since there is no hiding of information in java it does support op overloading === === === === === === Pranab Kumar Rana Software Engineer..... === === === ===
To concatenate strings in PHP, you use the . (dot) character. For example: $str = "String1" . "String2";
a write the algorithm to concatenate two given string
There are 5 operators which cannot be overloaded. They are: * .* - class member access operator * :: - scope resolution operator * . - dot operator * ?:: - conditional operator * Sizeof() - operator Note:- This is possible only in C++.
The dot (.) operator in PHP is used to concatenate strings. For instance:$start = "Big";$end = "Bird";echo $start . ' ' . $end;This code would produce the output:Big Bird
I will not use operator overloading in C# to do anything. Operator overloading may lead to one operator has more than 1 semantic meaning. For example, we know 1 + 2 yields 3, and "1" + 2 yields "12". I do not like this overloading of the operator + being used for addition in Number hierarchy, while as the concatenation in strings. That is, one operator (+) has 2 significant semantics.And the question "find largest of two object" is too vague - what do you mean "largest"? and object? We know apple and orange are 2 objects, but how do you compare them, and find the largest one?????? (size, price or what???)
In QBASIC, string operators allow you to manipulate and combine strings. The primary operator is the concatenation operator, which is the semicolon (;) or the plus sign (+). For example, you can concatenate two strings like this: result$ = "Hello" + " World", resulting in result$ containing "Hello World". You can also use the LEN function to get the length of a string and the MID$, LEFT$, and RIGHT$ functions for extracting parts of strings.
I think you mean operation overlord??? It is the American, Canadian and British offensive on Europe in World War 2. They landed in Normandy on 6th June 1944 (Commonly called D-Day, Day of Days or Deliverance Day) and progressed throughout France liberating Paris on the 25th August. This allowed the allies a foothold in Europe.
"+" is the concatenation operator in Java. It can be used to concatenate two strings. Ex: String firstName = "John"; String lastName = "Morrison"; System.out.println(firstName + " " + lastName); The above code snippet would display John Morrison in the console.