Can i overload operator == so it allow me compare two char[], C/C++ Programming

Q: Can I overload operator == so it allow me compare two char[] by a string comparison?

A: No: at least one operand of particular overloaded operator should be of some user-defined type (most of the time it means a class).

However even if C++ let you to do this, which it doesn't, you wouldn't wished to do it anyway as you really should be using a std::string-like class instead of an array of char in the first place since arrays are evil.

 

Posted Date: 3/20/2013 3:46:26 AM | Location : United States







Related Discussions:- Can i overload operator == so it allow me compare two char[], Assignment Help, Ask Question on Can i overload operator == so it allow me compare two char[], Get Answer, Expert's Help, Can i overload operator == so it allow me compare two char[] Discussions

Write discussion on Can i overload operator == so it allow me compare two char[]
Your posts are moderated
Related Questions
Project Description: I want someone who can post ads for me on Craiglist . I will pay 3$ per ad i need about 30-40 ads per day . Skills required: C Programming, MySQL, Jav


Operation on list - c++ program: Write a program in c to Insert value on list and list iteration. typedef struct item *node_ptr; struct item {                   int e

Create a program that asks the user for two integers which represent the numerator and denominator parts of fraction. Print out a simplification of the fraction. Example: Enter th

Question : (a) What is a structure? Provide a simple example of your own to illustrate this feature. (b) How does a structure differ from an array? (c) Describe a structu

write a program for convert numbers upto 9 to alphabet?Eg.now enter the inputis 666 means output is "0" lphabet

Unions A union is also like a structure, except that only single variable in the union is stored in the allocated memory at a time. It is a collection of mutually exclusive var

what happens when the following command is used? chmod u=rwx,go=r-x foo


A palindrome is a string that reads the same from both the ends. Given a string S convert it to a palindrome by doing character replacement. Your task is to convert S to palindrome