|
Hi,
you're doing something i don't get.
on the C Side you got
struct Time
{
int seconds,
int nanoseconds
};
and
struct Timer
{
struct Time time;
void (*callback)(struct Timer *timer);
};
The Timer struct encapsulates the Time struct, because in C you don't have inheritance. This is correct. But on the C++ side you got
class Time
{
public:
...
...
protected:
C::Time m_time;
};
and
class Timer : public Time
{
public:
...
...
protected:
static void callback(struct Timer *timer);
C::Timer m_timer;
};
Here you make some design error.
The class time encapsulates the 'c' Time struct and giving it some extra functionality. No problem so far. But you're class Timer inherits from the Time class and encapsulates the 'c' timer struct.
Giving you indeed twice the 'c' time struct. According to me this is a fault in the design. The 'C' and 'C++' counterparts are NOT equivalent.
To make the equivalent you should encapsulate either the 'C' Timer struct, or, inherit from the Time class and adding the needed Callback function. But you can't do both.
Why do you inherit from the time class?
Learn from the mistakes of others, you may not live long enough to make them all yourself.
|
|
|
|
|
<quote>Here you make some design error.
The class time encapsulates the 'c' Time struct and giving it some extra functionality. No problem so far. But you're class Timer inherits from the Time class and encapsulates the 'c' timer struct.
Giving you indeed twice the 'c' time struct. According to me this is a fault in the design. The 'C' and 'C++' counterparts are NOT equivalent.
To make the equivalent you should encapsulate either the 'C' Timer struct, or, inherit from the Time class and adding the needed Callback function. But you can't
You are absolutely right. This is the exact problem that i want to solve when writing C++ wrappers.
<quote>Why do you inherit from the time class?
Because the many API's associated with class Time are are also applicable for class Timer. Also, the code presented here is one of the simpler case. The other code that i use also have similar use cases but are somewhat more complex.
Cheers!
Kishore
|
|
|
|
|
I have an existing C++ mfc program that I need to modify. I need to make it parse an xml file to look for certain data. I have found that it is easier to do this parsing of the xml file using a vbscript. I am looking for a way to call the vbscript in my c++ code and capture return data from the script. Does anyone know how to do this? Or is there an easy way to search xml files using the old visual c++?
Rock
|
|
|
|
|
rocktx wrote: I have found that it is easier to do this parsing of the xml file using a vbscript.
Not so much. You would have to host a scripting engine to do that. Therefore it seems working with the MSXML interfaces would be simpler. Start with the following link, that page and all it's child pages should provide you with everything you need.
Get Ready to Work with MSXML (C/C++)[^]
led mike
|
|
|
|
|
I'm having a play with GDI+ drawing in one of my Apps.
I have an arbitrary region (made up of all sorts of wacky shapes) that I can draw semi-transparently over a bitmap using a brush with Alpha=64, and Graphics::FillRegion method.
Class GDI has a FrameRgn call which draws an outline of a region, but I can't find an equivalent in GDI+. While I could convert a Region to an HRGN, I'd lose some capability like scaling, which I need.
Has anyone solved this before? Am I being blind and missing some way of saying "you know that thing you're about to do? Use a hollow-but-edged-brush"...
Thanks,
Iain.
Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.
|
|
|
|
|
GraphicsPath::Outline() is the closest I've found.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks Mark.
I'll have a proper look tomorrow.
Iain.
Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.
|
|
|
|
|
I need to get the privilage set of user (Administrator,Guest ...)
Is any API is there to achieve this .. ?
vineesh
|
|
|
|
|
There's been several IsUserAnAdmin questions in the last few days...
Have a look at this reply to a question two days ago:
http://www.codeproject.com/script/Forums/View.aspx?fid=1647&msg=2628859[^]
Don't forget to look at the other answers too for information.
Going through the security SDK is a difficult thing. Lots of pointers and SID, and xIDs, and, and, and...
Iain.
Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.
|
|
|
|
|
vineeshV wrote: I need to get the privilage set of user (Administrator,Guest ...)
You can use NetUserGetInfo() for this.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi to all,
namepsace MyNamespace
{
class A
{
public :
void FunA();
};
class B
{
void FunB();
friend void A::FunA();
};
}
Above code compiles successfully.
But below given code generates error as error C2027: use of undefined type 'MyNamespace::B'
Please help me to resolve error in following code?
I am using VC++ 2008.
namepsace MyNamespace
{
class B;
class A
{
void FunA();
friend void B::FunB();
};
class B
{
public :
void FunB();
};
}
Thanks in advance.
Best Regards,
Aniket A. Salunkhe
|
|
|
|
|
|
Hi,
So friend class is the only solution to this?
Thanks & Regards,
Aniket A. Salunkhe
|
|
|
|
|
Aniket Salunkhe wrote: Please help me to resolve error in following code?
At this point, class B is known by the conmpiler, but B::FunB() is not. You can resolve the compiler error by simply replacing the forward declaration of B with the actual definition. Does this go against your design?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
DavidCrow wrote: Does that go against your design?
Yes.
|
|
|
|
|
do classes A and B have reciprocal references ?
otherwise, just put each classes into their own header, and include header of class B in header of class A
|
|
|
|
|
Hi,
My code looks like this.
namepsace MyNamespace{
class A
{
int a;
void FunA()
{
a = 10;
}
};
class B
{
int b;
A aObj;
public :
void FunB()
{
aObj.FunA();
}
};
}
Thanks & Regards,
Aniket A. Salunkhe
|
|
|
|
|
HI
Sending onemessage From RTF with BOLD,COLOR fonts to Flash ......But its displaying without BOLD,COLOR in Flash.....but i need display message in flash with BOLD,COLOR fOnt . ..
|
|
|
|
|
Please edit your previous post instead of reposting.
Regards,
Sandip.
|
|
|
|
|
HI
Sending onemessage From RTF with BOLD,COLOR fonts to Flash ......But its displaying without BOLD,COLOR.....but i need with BOLD,COLOR fOnt...
|
|
|
|
|
|
Hello everyone,
1.
Suppose using marshalling to transfer information from one apartment to another apartment, what communication protocol is used? HTTP? TCP? RPC?
2.
Is the communication secure? (Encrypted?)
thanks in advance,
George
|
|
|
|
|
I think you are maybe a bit confused by the term marshalling. It has nothing to do with a specific protocol (it is in fact the opposite: some protocols or technologies use marshalling in order to transmit information). Marshalling is only the action of transforming an object to a data format that can be transmitted or store. See here[^] for more information.
In that sense, there's no such thing as encryption at the marshalling level. On the other hand, the protocol that is using marshalling could also encrypt the transmition, but it is up to the protocol to do that.
|
|
|
|
|
Thanks Cédric,
1.
My current confusion is, I deploy two COM components in two different apartments, and I did not programming any protocol code, I am confused what communication protocol is used. Any ideas?
(As you said, marshalling has nothing to do with protocol, but I also do not program any protocol code. Which party actually implements the communication protocol to transfer object state from one apartment to another apartment?)
2.
I read through the link, my most confusion is what means "record its state and codebase(s)"? What mean codebase here? (looks like the link in Wikipedia for codebase is not good, because it is explained as source codes.)
regards,
George
|
|
|
|
|
Sorry but I'm a bit lost... COM components are (AFAIK) not used for distributed. Are you using DCOM component ? If yes, I can't tell you which protocol is being used. If the components are aimed to be distributed, then they will implemented that themselves I guess.
|
|
|
|