|
Thank for your answer but I was asking if it were possible
to create a new person whilst the program is running.
For instance, the user wishes to create a new person,
co-worker for instance, which uses the person structure.
Is it possible to create a new one without defining
it in the source code?
Thanks anyways!
|
|
|
|
|
struct person {
string name;
typedef enum {
BROWN = 1,
BLUE = 2,
GREEN = 3
} eyeColors_t;
eyeColors_t eye_colour;
float height;
friend istream& operator >> (const istream&, const person&);
};
istream& operator >> (istream& is, const person& p) {
is >> name >> eye_colour >> height;
return is;
}
|
|
|
|
|
Hmmm... that piece of code has given me an idea...
Thanks, V2.0 !
|
|
|
|
|
Define a constructor for your struct that takes name, eye_color and height as parameters (and has default values for all of them).
struct person
{
string name;
int eye_colour;
float height;
person(const string& n = "" , int e = -1 , float h = 0.0F);
};
person::person(const string& n, int e, float h)
: name(n), eye_color(e), height(h)
{}
Now you can create new instances of person easily:
person* spouse;
string newpersonname;
cin.get(newpersonname, 15);
cin.ignore(16,'\n');
spouse = new person(newpersonname);
|
|
|
|
|
Hmmm...
Does the second bit of code take 'spouse' as an example to make
'newpersonname' or does it erase 'spouse' in order to replace it
with 'newprersonname'?
Thanks anyways!
|
|
|
|
|
GetLogicalDriveStrings() can be used to get system driver stirngs in user mode app,if it can be used in driver program to do the same thing?
Thanks!
|
|
|
|
|
In my application i need to change brush attributes e.g color etc at run time,
consider following
CBrush b1;
b1.createSolidBrush(RGB(255,0,0));
now how can i change the color of same brushto green color?
An alternate option is to create new brush when it is needed and then destroy when its not, but this creation/destruction will slow down the prog, thats why i want to use only one brush and change its attributes as needed at run time
Thanks in advance
|
|
|
|
|
pc_dev wrote: An alternate option is to create new brush when it is needed
or create them both at the start of your app, and destroy them both at the end
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
hi Chris,
this has nothing to deal with the question you answered, but i wanted to know if you had received my mail, and if you have any particulier thoughts about it...
thanks,
v2.0
|
|
|
|
|
|
Thanks for reply.
Chris Losinger wrote:
create them both at the start of your app, and destroy them both at the end
If there were only two brushes needed then I would do the same but in my case i can't tell how much brushes will be needed, eg 1000.
in above case the best option is to create on eand change its attributes at run time.
|
|
|
|
|
pc_dev wrote: in above case the best option is to create on eand change its attributes at run tim
except that it's probably not possible to do that.
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
As far as I'm aware you don't - You create a new one.
Steve
|
|
|
|
|
Are you sure that creating/destroying the brush each time is that expensive? Try it and see how the program performs.
Software Zen: delete this;
|
|
|
|
|
Hi guys,
Can any one suggest me how i can write a very simple mouse hook?
suggest me some sample code.
Thanks,
Ram..
|
|
|
|
|
use SetWindowHookEx as follows
SetWindowsHookEx( WH_MOUSE, MouseProc,0,0);
u should write a function write a function(here "MouseProc") with prototype
LRESULT CALLBACK MouseProc( int nCode,
WPARAM wParam,
LPARAM lParam
);
Now u will get all the mouse messages in the function "MouseProc".
The above hook only works inside ur application scope. For u to make the hook globel u should have to write the "MouseProc" in a dll. and pass the instance(obtained from LoadLibrary) as the third parameter to the SetWindowsHookEx function.
nave
|
|
|
|
|
Hi Naveen,
Thanks..
As us said i am looking for a global mouse hook.
are there any rules for the dll like it should be a com outproc server or
is it enough to be ordinaly dll.
thanks and regards,
Ram
|
|
|
|
|
an ordinary dll is enough.
nave
|
|
|
|
|
Hello,
I'm using MS Visual Studio .NET 2003.
how can I get the total line count of the whole project?
Thanks in advance
|
|
|
|
|
|
Thanks. That was a very useful add-in.
|
|
|
|
|
SourceMonitor
"My dog worries about the economy. Alpo is up to 99 cents a can. That's almost seven dollars in dog money" - Wacky humour found in a business magazine
|
|
|
|
|
I wish to get certified in c++ and vc++ are there any exams for the same.
Can anyone pls. guide.
Arun.
|
|
|
|
|
|
Start your search here. Check here, too.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|