473,606 Members | 2,381 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2178
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.publ ic.vc.ide_gener al' 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
1086
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
1606
by: matt p | last post by:
example: FunClass myfun; FunClass *lotsofunptr=&myfun; myfun; //calls the overloaded operator; lotsofunptr->;//error help is much apreciated
7
1811
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 cout.operator<<(100);
13
5026
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 implement operator new/delete I can't see a way to indicate, on delete, how many objects must be destroyed (or how big the space is) - alternatively I can't figure out what are the alignment requirements so that the implementation, after calling my...
2
2107
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 the overloaded assignment operator function is allowed to be a non- member function then we may be able to write the following: Suppose we have a class Test for which operator+() is defined, suppose we have
4
3369
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
2049
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 the + operator by means of a friend function. Everything worked fine until I decided to use a variable array size (by using new/delete), now I get an error when a temporary object is deleted (e.g. after addition), the error occurs at the delete...
3
1511
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
6111
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); } };
0
7955
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8431
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8096
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8306
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
5966
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5466
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3937
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3980
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2448
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.