|
Hi, everyone!
Suppose I have a table in a database. The table has three
columns: "name", "birthday" and "password".
I want to do such operations:
1. query user by some condition
2. change user password and birthday
I use the following classes to describe the module. I want to
learn your suggestions about my design.
My Design:
--------
Class User {
string name;
string birthday;
string password;
changePassword()
{
...
}
changeBirthday()
{
...
}
}
class UserTable {
User* queryByCondition (string condition)
{
//query database by condition
//return an User array
}
}
--------
Thanks in advance,
George
|
|
|
|
|
I think that your encapsulation of User in a class is a good idea, but I wouldn't necessarily create a class to represent the table itself. It is normally better to create a data access layer to handle transactions with the database. You can just create this layer and ask it to populate your data object (User) for you. I would handle all database access this way, so the User class should have a base class that all data objects inherit from. If you do a search on google 'Data Access Layer', you should be able to gain a deeper understanding of the concept. Here is an interesting link I found with that search: http://www.15seconds.com/issue/020611.htm.
Best Regards and good luck.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
Hi everyone,
How can I use the XOR mode for the FillRect API call. I have a background bitmap and I want to highlight specific portion of it using the XOR mode.
Thanks,
Pankaj
Without struggle, there is no progress
|
|
|
|
|
To invert (= source xor -1) a rectangle you can use the InvertRect API.
-Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
|
|
|
|
|
When I compile my mfc-application in UNICODE mode, the unicode characters are displayed inocerrctly in a list window. But when I MessageBox() the unicode string, it's ok.
(When compiling as ansi, the unicode goes ????)
Any suggestions.
I know that the first message must be unicode, for windows to know that a new window should be unicode, but with UNICODE defined, this should be no issue, if not calling XxxA() which I don't.
|
|
|
|
|
Remember to define both UNICODE and _UNICODE
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Hiya what is the best way to completely clear a structure for re-use. Want to initialize it with 0 when program starts.
This is my structure:
struct s_Worked
{
char DaysWorked[15];
}Worked[100];
Thanks,
grahamoj
|
|
|
|
|
I use the ZeroMemory API function when possible.
ZeroMemory(&YourStruct, sizeof(YourStruct)); or
memset(&YourStruct, 0, sizeof(YourStruct)); -Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
|
|
|
|
|
I use this template class.
<br />
template <class T, int FILL=0> class auto_zap : public T<br />
{<br />
public:<br />
auto_zap()<br />
{<br />
memset(static_cast<T *>(this), FILL, sizeof(T));<br />
}<br />
<br />
void zap()<br />
{<br />
memset(static_cast<T *>(this), FILL, sizeof(T));<br />
}<br />
<br />
auto_zap<T> & operator=(const T &rhs)<br />
{<br />
*static_cast<T *>(this) = rhs;<br />
return *this;<br />
}<br />
};<br />
--------
There are 10 types of people in this world. Those who know binary and those who don't.
|
|
|
|
|
Try this:
struct s_Worked
{
char DaysWorked[15];
} Worked[100] = { 0 };
Software Zen: delete this;
|
|
|
|
|
Hi, everyone!
There are two operator >> overload functions in my class. And
both work OK. I have read some codes by others that the
function which overloading operator >> usually has two forms. One form
is returning null and another form is returning ostream&.
I want to know what is the difference between them. Which way is
better or in which case should I use the first form and vice versa.
Codes:
--------
#include <iostream>
#include <fstream>
using namespace std;
class A {
private:
int a;
public:
A (int a)
{
this->a = a;
}
operator << (ostream& os)
{
os << a;
}
ostream& operator << (ostream& os)
{
os << a;
return os;
}
};
int main()
{
A a(10);
ofstream f ("c:\\test.txt");
a << (f);
return 1;
}
--------
Thanks in advance,
George
|
|
|
|
|
You should implement your overload as returning an ostream& , so that you can concatenate several >> operations in the same sentence. COnsider for instance:
ostream os;
...
A a;
int i;
os>>a>>i; The last sentence is equivalent to
(os>>a)>>i or, tu put it more clearly
os.operator>>(a).operator>>(i); If your overload returned void , clearly the sentence would make no sense. So it is always better to return an ostream& . The impact on efficiency is usually negligible, or even none at all if the function is inlined.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks, Joaquín buddy!
George
|
|
|
|
|
can somebody help in finding out,how to display a number in local currency format? Is there any function that converts a nuber into the local currency?
|
|
|
|
|
GetCurrencyFormat() is what you are after.
|
|
|
|
|
hi there,
i've made an IE toolbar with several custom drawn buttons
the buttons are made with a blank icon, and then i override the drawing using the custom draw notification.
Everything works fine when IE is maximized, but when i start scaling down the IE, the behaviour is as follows:
-those icons on the far right which are found to be with separators, will start to be clipped away.E.g. between 2 separators there are 4 icons. As soon as the last icon, is partially hidden, all 4 buttons are clipped away
-when a certain amount of pixels of the toolbar are hidden, this weird clipping doesn't occur anymore on the remaining buttons. I confirmed this since if i make big indent for the start of the buttons (say 300 pixels), the strange behaviour of clipping away buttons will manifest itself at the same point.
any ideas?? this is freaking me out
cheers
nev
|
|
|
|
|
i fixed YAAAAAAAAAAAAY
just had to turn off TBSTYLE_WRAPABLE
|
|
|
|
|
Anybody knows about DDI Hooking?
vikramS
|
|
|
|
|
|
thanx for the suggestion But I went thr those links before ..looking for more help
|
|
|
|
|
Hi, everyone!
I am reading the source codes of another buddie and
I often see strange operation with "this" pointer.
It really makes puzzled. Here are two cases,
Sample 1:
--------
class A {
public:
memberFunction(const A& a)
{
*this = a;
}
};
int main()
{
A a;
A b;
a.memberFunction(b);
return 1;
}
--------
I think in the first case, the statement "*this = a" calls the
class default assignment operator,
--------
void A::opeartor = (const A&).
--------
Am I correct?
Sample 2:
--------
class A {
public:
void memberFunction(A* a)
{
this = a;
}
};
int main()
{
A a;
A b;
a.memberFunction(&b);
return 1;
}
--------
I think in the latter case, the statement "this = a" is not correct since
the value of this pointer can not be modified. But I am not sure about
it. Am I also correct?
Thanks in advance,
George
|
|
|
|
|
Assigning a value to this is illegal, so your example 2 will not compile.
By the way, the word is spelled "buddy"
--Mike--
THERE IS NO THERE IS NO BUT THERE IS
MAGIC PIXIE DUST BUSINESS GENIE CODE PROJECT
Homepage | RightClick-Encrypt | 1ClickPicGrabber
"You have Erica on the brain" - Jon Sagara to me
|
|
|
|
|
Thanks, Michael buddie!
Is my options correct in example one?
regards,
George
|
|
|
|
|
Yes, the compiler will try to generate an assignment operator if you do not write one yourself. If the class contains members which are themselves classes, this may not end up doing what you want, so when in doubt it's best to write the assignment operator and copy constructor.
--Mike--
THERE IS NO THERE IS NO BUT THERE IS
MAGIC PIXIE DUST BUSINESS GENIE CODE PROJECT
Homepage | RightClick-Encrypt | 1ClickPicGrabber
"You have Erica on the brain" - Jon Sagara to me
|
|
|
|
|
Thanks, Michael buddy!
George
|
|
|
|