Click here to Skip to main content
Click here to Skip to main content

view the contents of BSTR in debugger? good tips and notes

, 22 Jun 2005
Rate this:
Please Sign up or sign in to vote.
view the contents of BSTR in debugger

Introduction

First, be sure to enable display of Unicode strings via:

Tools/Options/Debug/Display Unicode strings. This should enable viewing of BSTR types.

Wrappers for BSTR, though, still cause problems.

To display _bstr_t types add this to your \DevStudio\SharedIDE\bin\autoexp.dat file.
_variant_t =vt=<vt,x> str=<bstrVal,su> short=<iVal>
long=<lVal>dbl=<dblVal,g>
_bstr_t =<m_Data->m_wstr,su>
tagVARIANT =vt=<vt,x> str=<bstrVal,su> short=<iVal>
long=<lVal>dbl=<dblVal,g>

********************************************

Difference Between linked list and array

In Linked list, we allocate memory as much as needed at run time while in array we have to allocate memory at compile time.

linklist is dynamic allocation. and array is a static allocation

easy to remove the node of linked list, hard to remove a cell of an array, you have to shift the rest cells, it will be expensive.

You can find data quickly in array as long as specifying the index. However, in linked list, you need start from the header, takes O(N) times.

Array can store only homogeneous content. That is objects of the same type. So type casting is not required

advantages of array over linkedlist is we can access the values arbitarily but in
linked lists we have to access the data sequentially.

*******************

templates:

C++ templates allow to implement a generic class..code reuse..

The basic syntax for declaring a templated class is as follows:

template <class a_type> class a_class {...};

The keyword 'class' above simply means that the identifier a_type will stand for a datatype. NB: a_type is not a keyword; it is an identifier that during the execution of the program will represent a single datatype. For example, you could, when defining variables in the class, use the following line:

a_type a_var;

and when the programmer defines which datatype 'a_type' is to be when the program instantiates a particular instance of a_class, a_var will be of that type.

When defining a function as a member of a templated class, it is necessary to define it as a templated function:

template<class a_type> void a_class<a_type>::a_function(){...}

When declaring an instance of a templated class, the syntax is as follows:

a_class<int> an_example_class;

An instantiated object of a templated class is called a specialization; the term specialization is useful to remember because it reminds us that the original class is a generic class, whereas a specific instantiation of a class is specialized for a single datatype (although it is possible to template multiple types).

Usually when writing code it is easiest to precede from concrete to abstract; therefore, it is easier to write a class for a specific datatype and then proceed to a templated - generic - class. For that brevity is the soul of wit, this example will be brief and therefore of little practical application.

We will define the first class to act only on integers.

class calc

{

public:

int multiply(int x, int y);

int add(int x, int y);

};

int calc::multiply(int x, int y)

{

return x*y;

}

int calc::add(int x, int y)

{

return x+y;

}

We now have a perfectly harmless little class that functions perfectly well for integers; but what if we decided we wanted a generic class that would work equally well for floating point numbers? We would use a template.

template <class A_Type> class calc

{

public:

A_Type multiply(A_Type x, A_Type y);

A_Type add(A_Type x, A_Type y);

};

template <class A_Type> A_Type calc<A_Type>::multiply(A_Type x,A_Type y)

{

return x*y;

}

template <class A_Type> A_Type calc<A_Type>::add(A_Type x, A_Type y)

{

return x+y;

}

To understand the templated class, just think about replacing the identifier A_Type everywhere it appears, except as part of the template or class definition, with the keyword int. It would be the same as the above class; now when you instantiate an

object of class calc you can choose which datatype the class will handle.

calc <double> a_calc_class;

Templates are handy for making your programs more generic and allowing your code to be reused later.

 

 *********************

nice puzzle

I have a scale and 7 balls. 1 ball is heavier than all the rest. How do I determine the heaviest ball with only 3 possible weighing attempts?

Answer: I can do it in 2 attempts.

1. Take one out.
2. Balance the 6 on the scale, 3 on each side.
3. If they balance, the one sitting out is the culprit
4. If one side goes down, we have narrowed down to 3 balls
5. Take one out. Now balance the two remaining.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Blue_Aqua
Web Developer
India India
Think good and good will happen...

Comments and Discussions

 
GeneralDebugging UNICODE strings Pinmemberkacza23-Jun-05 21:00 
GeneralRe: Debugging UNICODE strings PinmemberBlue_Aqua23-Jun-05 21:10 
Cheers..Smile | :)

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

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

| Advertise | Privacy | Mobile
Web01 | 2.8.140827.1 | Last Updated 23 Jun 2005
Article Copyright 2005 by Blue_Aqua
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid