473,385 Members | 1,569 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

quick watch of an overloaded operator

All,

I have seemingly quite known problem, namely I need to watch overloaded
[] in quick watch(by own vector) but I can not. It says overloaded
operator is not found. And that is claimed normal here (at least once).

But I have a project where at least for local class variables [] can be
watched. I see absolutely no difference in settings/options, and the
class is just copied from old project. Ans it is template class (if it
does matter).

template <class T>
class CVector
{

public:

//! Number of elements of the vector.
int m_nLength;
//! Pointer to elements of the vector
T* p;

........

//! Get ith element of a vector. use as vector[i]
T& operator[] (int i) const
{
return p[i];
}

..............

}

making this inline operator (if it indeed become one) does not help.

Not very important but still would be better to find a way to watch...
Has somebody any idea?

And yes, things should be private, I know...

Sep 26 '05 #1
4 2154
vladimir wrote:
I have seemingly quite known problem, namely I need to watch overloaded
[] in quick watch(by own vector) but I can not. It says overloaded
operator is not found. And that is claimed normal here (at least once).

But I have a project where at least for local class variables [] can be
watched. I see absolutely no difference in settings/options, and the
class is just copied from old project. Ans it is template class (if it
does matter).

template <class T>
class CVector
{

public:

//! Number of elements of the vector.
int m_nLength;
//! Pointer to elements of the vector
T* p;

.......

//! Get ith element of a vector. use as vector[i]
T& operator[] (int i) const
Bad idea. You're returning a non-const reference to something that is
stored in an object that can be 'const'. If it's a const vector, why
would you allow changing its contents? I know, I know, syntactically,
only 'p' and 'm_nLength' are const, not what 'p' points to, but still.
{
return p[i];
}

.............
What's here? Could it be you also provided

operator T*() { return p; }

??? You shouldn't, you know.

}

making this inline operator (if it indeed become one) does not help.

Not very important but still would be better to find a way to watch...
You keep using the verb "watch" here. Why? How is it relevant?
Has somebody any idea?

And yes, things should be private, I know...


It doesn't matter, most likely. What matters, though, is FAQ 5.8.

V
Sep 26 '05 #2
Old code isn`t mine actualy. I am doing it now according to all rules,
but I can not answer other's question "why it is not possible to use MS
Visual C++ Quick Watch function (basically, highlite a[1] inclusion and
see value) while debugging whereas it was possible with old class?" In
new project old class does not do it either, and all sources I could
reach says it is normal not to see it in quick watch. But I see it!!!
How to reach this functionality with my new improved class is my main
and only concern.

Sep 26 '05 #3
Old code isn`t mine actualy. I am doing it now according to all rules,
but I can not answer other's question "why it is not possible to use MS
Visual C++ Quick Watch function (basically, highlite a[1] inclusion and
see value) while debugging whereas it was possible with old class?" In
new project old class does not do it either, and all sources I could
reach says it is normal not to see it in quick watch. But I see it!!!
How to reach this functionality with my new improved class is my main
and only concern.

Sep 26 '05 #4
vladimir wrote:
Old code isn`t mine actualy. I am doing it now according to all rules,
but I can not answer other's question "why it is not possible to use MS
Visual C++ Quick Watch function (basically, highlite a[1] inclusion and
see value) while debugging whereas it was possible with old class?"
Since you didn't post the "old class", I have no idea why there is any
difference between the two. However, I can probably answer your question
partially.

First of all, "Visual C++ Quick Watch" is off-topic here. You should try
'microsoft.public.vc.ide_general' newsgroup for questions about Microsoft
Visual C++ IDE.

Second of all, when "watching" something in a debugger requires a function
call (like with your overloading operator[]), the debugger most likely
will *not* be able to display anything because the *debugger* has no idea
how to call a function. In that case you should examine the object itself
(in your case 'a') and see the 'p' member and index that array manually in
the debugger.

Good luck, and next time post a C++ _language_ question. Any *tools* like
debuggers, compilers, linkers, editors, etc., are most likely off-topic
here and should be discussed in their own respective newsgroups.
[...]


V
Sep 26 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Surya Kiran | last post by:
Hi all, I've a class template, of which i've an overloaded operator (operator <<) which was written like this =============== classa.hpp =========== template <class T> class A { .... ....
3
by: matt p | last post by:
example: FunClass myfun; FunClass *lotsofunptr=&myfun; myfun; //calls the overloaded operator; lotsofunptr->;//error help is much apreciated
7
by: John | last post by:
I always understood that in C++, if I said a + b a.operator+(b) is called. Now this makes sense with the operator<< when used in the following way cout << 100; // converts to ...
13
by: Tristan Wibberley | last post by:
Hi I've got implementing overloaded operator new and delete pretty much down. Just got to meet the alignment requirements of the class on which the operator is overloaded. But how does one...
2
by: subramanian100in | last post by:
overloaded operator=() -------------------------------- overloaded assignment operator should be a non-static MEMBER function of a class. This ensures that the first operand is an lvalue. If...
4
by: abendstund | last post by:
Hi, I have the following code and trouble with ambiguity due to operator overloading.. The code is also at http://paste.nn-d.de/441 snip>>
9
by: itdevries | last post by:
Hi, I've ran into some trouble with an overloaded + operator, maybe someone can give me some hints what to look out for. I've got my own custom vector class, as a part of that I've overloaded...
3
by: sam.barker0 | last post by:
Hi, I have designed a class with an overloaded = operator. The problem is that whenever I invoke the method like const myclass<charastring=another_object;
8
by: Rahul | last post by:
Please read the following code class Test{ public: void * operator new (size_t t) { return malloc(t); } void operator delete (void *p) { free(p); } };
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.