Click here to Skip to main content
15,887,596 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: operator () overloading. Pin
9ine23-Feb-06 1:01
9ine23-Feb-06 1:01 
GeneralRe: operator () overloading. Pin
BadKarma23-Feb-06 3:44
BadKarma23-Feb-06 3:44 
GeneralRe: operator () overloading. Pin
9ine23-Feb-06 5:26
9ine23-Feb-06 5:26 
GeneralRe: operator () overloading. Pin
BadKarma23-Feb-06 8:29
BadKarma23-Feb-06 8:29 
QuestionCrystal Reports 11 with visual Studio .NET Pin
Irfan Shahid23-Feb-06 1:04
Irfan Shahid23-Feb-06 1:04 
QuestionRe: operator () overloading. Pin
David Crow23-Feb-06 3:41
David Crow23-Feb-06 3:41 
AnswerRe: operator () overloading. Pin
9ine23-Feb-06 5:18
9ine23-Feb-06 5:18 
GeneralRe: operator () overloading. Pin
David Crow23-Feb-06 5:45
David Crow23-Feb-06 5:45 
9ine wrote:
how can we handle this in one &operator() and class


Short of using a template, I do not know of a way. If you added another operator[] to the class, the compiler will complain because the formal parameter list between the two would be identical.

Now if you wouldn't mind replacing operator[] with an actual method (e.g., getChar(), getFloat()), you could get this to work.

Templates are not as difficult as you might think. Consider:

template <class T> class vec
{
    public:
 
        vec()
        {
            data = new T[5];
        }
 
        ~vec()
        {
            delete [] data;
            data = NULL;
        }
 
        T &operator[]( const int nIndex )
        {
            return data[nIndex];
        }
 
    private:
 
        T *data;
};
...
vec<char> c;
c[0] = 'z';
char q = c[0];
vec<float> f;



"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain



-- modified at 12:31 Thursday 23rd February, 2006
GeneralRe: operator () overloading. Pin
9ine23-Feb-06 22:59
9ine23-Feb-06 22:59 
GeneralRe: operator () overloading. Pin
David Crow24-Feb-06 2:42
David Crow24-Feb-06 2:42 
GeneralRe: operator () overloading. Pin
9ine24-Feb-06 3:00
9ine24-Feb-06 3:00 
QuestionRe: operator () overloading. Pin
David Crow24-Feb-06 3:08
David Crow24-Feb-06 3:08 
AnswerRe: operator () overloading. Pin
9ine25-Feb-06 1:08
9ine25-Feb-06 1:08 
GeneralRe: operator () overloading. Pin
jhwurmbach23-Feb-06 22:20
jhwurmbach23-Feb-06 22:20 
GeneralRe: operator () overloading. Pin
9ine23-Feb-06 22:53
9ine23-Feb-06 22:53 
GeneralRe: operator () overloading. Pin
jhwurmbach23-Feb-06 23:24
jhwurmbach23-Feb-06 23:24 
AnswerRe: operator () overloading. Pin
Wim Engberts23-Feb-06 5:47
Wim Engberts23-Feb-06 5:47 
JokeRe: operator () overloading. Pin
jhwurmbach23-Feb-06 22:21
jhwurmbach23-Feb-06 22:21 
QuestionStarting a process in the background no console Pin
theprinc22-Feb-06 23:00
theprinc22-Feb-06 23:00 
AnswerRe: Starting a process in the background no console Pin
Nibu babu thomas22-Feb-06 23:04
Nibu babu thomas22-Feb-06 23:04 
GeneralRe: Starting a process in the background no console Pin
theprinc22-Feb-06 23:21
theprinc22-Feb-06 23:21 
AnswerRe: Starting a process in the background no console Pin
David Crow23-Feb-06 3:44
David Crow23-Feb-06 3:44 
QuestionFormat a CString value from longdate to shortdate Pin
Kalthoff22-Feb-06 22:38
Kalthoff22-Feb-06 22:38 
AnswerRe: Format a CString value from longdate to shortdate Pin
toxcct22-Feb-06 22:43
toxcct22-Feb-06 22:43 
GeneralRe: Format a CString value from longdate to shortdate Pin
Kalthoff22-Feb-06 23:45
Kalthoff22-Feb-06 23:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.