|
Unicode? If I recall correctly it's possible to have keys that regedit can't display correctly.
Thus, if you copy and paste you're not copying the entire key. I'd write a quick and dirty iteration
over the root key dumping the raw bytes in each key name to make sure you have the entire key.
|
|
|
|
|
I wrote the following header file. Actually, what I posted is only a subset of
the header file:
#include <assert.h>
using namespace std;
template class {T> class Polynomial {
public:
Polynomial <T>() : order(-1), coeff( 0 )
{
}
Polynomial <T> ( int order, ... );
T eval( T xValue );
Polynomial & Integrate();
void printIt( ostream &out );
friend ostream & operator << ( ostream &out, Polynomial<T> &poly );
private:
int order;
T *coeff; // Note the lower order terms of the polynomail go first. That
// is for the polynomial x^10 - 5 coeff[0] = -5, coeff[10] = 1
// and all the other values of coeff are 0.
};
typedef Polynomial<double> DoublePolynomial;
Now in the file, poly.cpp, I define the member functions for this class. I also
instantiated the class with the statement:
template class Polynomial<double>;
However, this does not instantiate the operator << . Therefore, if in the main
program I write something like:
cout << poly1 << endl;
where poly1 is of type Polynomail<double> I get an error from the linker. I believe that this
is due to the fact that I did not instantiate the operator << which is a friend of the class.
I am hoping that somebody can tell me how to do this.
Thanks
Bob
|
|
|
|
|
I've found this C++ Faq[^] helpfull on template linkage errors. I must admit that I usually put all the declarations in the header file myself to avoid the problems. Putting the declaration for operator << in the header file resolves the linker error.
I'm a bit puzzled why you bothered with the friend operator << at all, since you have a public printIt function, which presumably is called by the operator <<. The friend keyword allows the function access to the internals (private and protected) parts of the class, with a printIt method you don't need this.
You could get the same effect by putting a stand alone template function in the header instead, e.g.
template<class T>
ostream & operator << ( ostream &out, Polynomial<T> &poly )
{
poly.printIt(out);
return out;
}
Graham
Librarians rule, Ook!
|
|
|
|
|
Graham,
I want to thank you for your response. It has solved my problem. I am not a big fan of using
the operator << to print the results. I feel that this is best done by a member function. Therefore,
I wrote the function printIt. Therefore the operator << just needs to call printIt. I am also not
a big fan of using the keyword friend. I feel that giving non-member functions access to private data
of a class is not a good idea.
Bob
|
|
|
|
|
What are the limits of the drawing area in GDI?
I am using MoveTo(x, y), LineTo(x, y) GDI functions to draw multiple line. LineTo fails (returns FALSE) when the y is more than 1073741951 units.
GetLastError() return error code 534 - "Arithmetic result exceeded 32 bit"
So friends, any advice?
Thanks in advanced
Sandip
|
|
|
|
|
Calculations are probably done with 32-bit integers,
so you'll need to keep your coordinates scaled
to prevent the overflow. Pinning down an exact limit
would be difficult unless you know the actual calculations
being done by the system.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Both GDI and GDI+ are limited to 1073741951 pixel extents on both vertical and horizontal axis.
Best Wishes,
-David Delaune
|
|
|
|
|
Hello everyone,
I am shamed to ask this question because I can not figure out after some experiment. I think for reference variable, once it is binded, the target can not be changed.
But why in my following sample, pi can be binded to a and later binded to b without any issues?
int main()
{
int a = 10;
int b = 20;
int& pi = a;
pi = b;
return 0;
}
thanks in advance,
George
|
|
|
|
|
I don't know what you mean by "binded".
All you are doing is assigning a value to a variable...
You are free to assign any value to a non-const variable,
as many times as you want to.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks Mark!
Cool.
regards,
George
|
|
|
|
|
Heh don't thank me - my reply made no sense.
Jijo and Nemanja have it right
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Good man, thanks Mark! Participation is also appreciated.
regards,
George
|
|
|
|
|
George_George wrote: int& pi = a;
In this statement you're initializing your reference variable. Now pi refers to variable a .
George_George wrote: pi = b;
In this statement you're assigning a value to your reference variable which will updates the value of variable a . Don't get confused - This is not re-initialization, Its just assignment.
George_George wrote: I think for reference variable, once it is binded, the target can not be changed.
Yes. Thats right. You cannot re-initialize a reference.
<modified with respect to Mark's comment>
Once reference is initialized and binded to one variable, you cannot re-initialize it or re-bind it to point another variable. But in your case, the statement pi = b; is just assignment. Thats why its legal.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
modified on Sunday, August 10, 2008 1:33 AM
|
|
|
|
|
Jijo raj wrote: Yes. Thats right. You cannot re-initialize a reference.
What do you mean by that?
*edit* I see - you were illustrating the difference between<br />
initialization and assignment, right?
Thanks,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote:
*edit* I see - you were illustrating the difference between
initialization and assignment, right?
Yes Mark.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Cool, thanks Jijo!
regards,
George
|
|
|
|
|
Binding? the use of reference variable is that it can be made to point to anything. Imagine it like a minutes pointer in a wall Clock. It can be rotated any degree to point to I,II,III,IV . here a,b is just like the I, II. You can turn your reference onto anything. No binding happens, but "referencing".
|
|
|
|
|
|
George_George wrote: But why in my following sample, pi can be binded to a and later binded to b without any issues?
It is not. The line
pi = b;
does not bind pi to b , but assignes a new value to a
|
|
|
|
|
You are correct, Nemanja!
regards,
George
|
|
|
|
|
Hi, I just want to know if it's possible to access a vector object by it's unique id.
In vector objects don't have id's you can just access them by their locations!
for example:
std::vector<myobject> objs;
objs.at(1).my_property = 'qwerty';
here 1 is the location of the object in that vector and it's not unique..
it can change if you delete or add a object on top of this object.
but i want to give them a unique id and access them by that.
Any suggestions?
|
|
|
|
|
you must use a std::map instead if you want to identify a record with a unique key.
|
|
|
|
|
Hi all,
i m using *.chm as a help file of application.i m open this through menu of application.
In help file diffrent categories like Contents,Index,Search,Favorite etc.
i want if i click on contents menu than help file open with Contents category,same for others.
so please tell me how can i do this.
Thanks in advance.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
Hi all,
i am trying to use a vista icon in my vc2005 application, by vista i mean that it changes it size according to its view. Now when i import that icon in my application and compile that application it gives error
error RC2176 : old DIB in G:\all__size_ico\Custom Software Box CD.ico; pass it through SDKPAINT
..
How to resolve this error???
Can anybody help me in this...
thanks in advance
|
|
|
|
|