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
How many levels deep can include files be nested? - As such, there is no limit to number of levels of nested include files you can have however your compiler might run out of s

fine the class bankAccount to implement the basic properties of a bank account. An object of this class should store the following data: Account holder''s name (string), account nu

In this problem you are given a board in which some of the elements are placed as shown in diagram below. Each element represents a color. Fill the other elements in the board, suc

requiredrequiredrequiredrequiredrequiredrequiredrequiredrequired

volume of a sphere

The Special Pointer 'this' When various instances of a class come into existence, it naturally follows that each instance has its own copy of member variables. If this were not

Create an array of Strings and fill it with some interesting text, such as vacation destinations, album names, or weapon names from a CRPG. Display three elements of the array on t

Memory management by c program: Write a program to memory management in c program unsigned max( unsigned, unsigned );   int BaseMemBlocks::allocBlock( size_t sz )

Define Storage Classes of c program - computer programming? Each variable and function in C language has two attributes that are type and storage class. If storage class of a v

A:BinaryHeap.h ------------ #ifndef BINARY_HEAP_H_ #define BINARY_HEAP_H_ #include "dsexceptions.h" #include "vector.h" // BinaryHeap class // CONSTRUCTION: wi