|
That's an interesting question! The issue is that contrary to what one might expect, typedef const Ty* const_pointer does not translate to typedef const int** const_pointer when Ty is int . Instead, it translates to typedef int * const * const_pointer . Consequently, the following code does compile with VC9.
template <typename T>
class Sample
{
public:
typedef const T* const_pointer;
typedef const T& const_reference;
const_pointer address( const_reference ref ) const
{
return &ref;
}
};
int main()
{
Sample<int*> s1;
int val = 10;
int * const pval = &val;
int * const & ref = pval;
int * const * p = s1.address( ref );
return 0;
}
--
gleat
http://blogorama.nerdworks.in[ ^]
-- Number Two's eyes narrowed and became what are known in the Shouting and Killing People trade as cold slits, the idea presumably being to give your opponent the impression that you have lost your glasses or are having difficulty keeping awake. Why this is frightening is an, as yet, unresolved problem. -- HHGTG
|
|
|
|
|
When to delete ILayer is Initiated in the below case
ABC::ABC
(
CScope_i* scope
):
AsObject(scope),
itsSppAst(new ILayer::Ast(scope->cppScope().Handle()))
{
//
}
|
|
|
|
|
ptr_Electron wrote: When to delete ILayer is Initiated in the below case
What ? You mean you want to know how to delete the ILayer instance that was created by new ?
Well, that depends a lot of what itsSppAst is... It becomes the only owner of the pointer so it is the only one that is able to delete it. If you don't have access to this class, then you will need to store a ILayer instance in your ABC class and create itsSppAst later, after you created your ILayer instance (you will need to use new in that case).
BTW, your indentation is awfull, it took me quite some time to understand your code which is rather simple.
|
|
|
|
|
This question makes little sense. Please elaborate.
--
gleat
http://blogorama.nerdworks.in[ ^]
-- Number Two's eyes narrowed and became what are known in the Shouting and Killing People trade as cold slits, the idea presumably being to give your opponent the impression that you have lost your glasses or are having difficulty keeping awake. Why this is frightening is an, as yet, unresolved problem. -- HHGTG
|
|
|
|
|
Actually there was some memory leak in the application, I am just go thought the code manually to find them, well on my way, I found a new, so just want to know, wheather I sould care it or neglact it
|
|
|
|
|
The rule is extremly simple: if you want to avoid memory leaks, for each call to new, you should have a corresponding call to delete (the same with new[] and delete[]).
|
|
|
|
|
Thanks, But my question is, does the same work for, in the above mentioned case of new, if yes, how can I do that
|
|
|
|
|
Of course, why would that be different ? You create an object using new, so you must delete it using delete, that's it.
Didn't you read my first reply ? I explained you there how to do that.
|
|
|
|
|
Hi all,
i m using progress.when i run my application its display in blue color .
i want when i run application on XP or Vista OS the progress bar looks like xp prgressbar or vista style progress bar.
please help me for 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
|
|
|
|
|
"_$h@nky_" wrote: i want when i run application on XP...the progress bar looks like xp prgressbar...
Are you referring to the PBS_SMOOTH style?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
I have a legacy C app which uses FFmpeg APIs.
I'm trying to update it, I want to write a UI in C# and keep the core in C.
So, i'm dabbling in C++/CLI for the first time.
It's my understanding that I can create a managed class wrapper, and have managed methods which take managed parameters, convert them as necessary to unmanaged equivalents (with System.Runtime.InteropServices.Marshal methods), do the work in native C, and then convert outputs from unmanaged to managed types for return.
However, I'm stuck at the start. I've created a class like this:-
ref class FFmpegCap
{
public:
FFmpegCap(String^ inputVideo);
protected:
AVFormatContext *m_pFormatContext;
};
In my constructor, i need to call a C FFmpeg function to initialise the library, one of the parameters it requires is of type AVFormatContext ** . So, I call this function as follows:-
if (av_open_input_file(&m_pFormatContext, pInputVideo ,NULL,0,NULL) != 0)
{
}
However, this fails to compile; error C2664: 'av_open_input_file' : cannot convert parameter 1 from 'cli::interior_ptr<type>' to 'AVFormatContext **'
It seems that the & operator is not doing what I expect of it!
Any pointers?
Thanks
Jon
|
|
|
|
|
There is a C++/CLI forum where you may get faster answers.
Then again, one of the other people here may be typing an answer at the same time as me...
Good luck,
Iain
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
Thanks Iain, I should use my eyes more I think.
|
|
|
|
|
I am using CProperySheet and CPropertyPage in my application for creating tabbed dialog boxes.
For providing the RTL layout, I am using the WS_EX_LAYOUTRTL for Property Sheet and Property Pages both.
This is doing well.
The Titla bar ( System control and min/max/restore buttons) are now in RTL layout.
Tabs contents are also in RTL layout. However two issues are still remaining opened-
1. OK and CANCEL buttons (that were in the Right Side of the screen before applying WS_EX_LAYOUTRTL style) are now in the Middle of the screen. They should be in the Left of the screen.
(Point to notice is that i have hide the "Help" and "Apply" buttons.)
2. Tabs (Tab Bar) are still coming in the Left side of the screen. No effect of the RTL layout on the tabs (Tab Bar) alignment or in their order.
<br />
void CAllControlsSheet::AddControlPages()<br />
{<br />
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);<br />
m_psh.dwFlags |= PSP_USEHICON;<br />
m_psh.hIcon = m_hIcon;<br />
m_psh.dwFlags |= PSH_NOAPPLYNOW;
m_psh.dwFlags |= PSH_RTLREADING ; <br />
m_psh.dwFlags &= ~PSH_HASHELP;
<br />
Invalidate();<br />
<br />
AddPage(&m_treectrlpage);<br />
AddPage(&m_animctrlpage);<br />
AddPage(&m_toolbarpage);<br />
AddPage(&m_datetimepage);<br />
AddPage(&m_monthcalpage);<br />
<br />
}<br />
<br />
BEGIN_MESSAGE_MAP(CAllControlsSheet, CPropertySheet)<br />
ON_WM_QUERYDRAGICON()<br />
ON_WM_SYSCOMMAND()<br />
END_MESSAGE_MAP()<br />
<br />
<br />
BOOL CAllControlsSheet::OnInitDialog()<br />
{<br />
<br />
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);<br />
ASSERT(IDM_ABOUTBOX < 0xF000);<br />
<br />
CMenu* pSysMenu = GetSystemMenu(FALSE);<br />
if (pSysMenu != NULL)<br />
{<br />
CString strAboutMenu;<br />
strAboutMenu.LoadString(IDS_ABOUTBOX);<br />
if (!strAboutMenu.IsEmpty())<br />
{<br />
pSysMenu->AppendMenu(MF_SEPARATOR);<br />
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);<br />
}<br />
}<br />
<br />
SetIcon(m_hIcon, TRUE);<br />
SetIcon(m_hIcon, FALSE);<br />
ModifyStyleEx(0, WS_EX_LAYOUTRTL); <br />
return CPropertySheet::OnInitDialog();<br />
}<br />
<br />
modified on Monday, January 12, 2009 9:45 AM
|
|
|
|
|
I have a word containing umlauts that I need to put on a toolbar button in Word. The project is an ATL/COM addin for MS Word (ANSI build).
The umlauts come out as Cyrillic letters even though our test machine is running a German-localized version of Windows.
This code for example produces correct text in the message box and a Cyrillic letter instead of an umlaut in the Word toolbar:
spButton->PutCaption(L"Öffnen");
::MessageBox(0, "Öffnen", 0, 0);
PutCaption accepts _bstr_t variable as argument, and wants unicode input. And I think that there are two types of umlauts - an ANSI variant which works only if the code page is set to german, and a 16-bit unicode variant, but I'm not sure about that.
And since the cpp file is encoded as ANSI it might be that Word gets an ANSI umlaut when it wants a unicode umlaut.
Is that so or not? And how do I fix the problem in either case?
Thanks.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
modified on Monday, January 12, 2009 10:08 AM
|
|
|
|
|
I don't know if you're right or not - but it sounds plausible.
What you could do is to put the text in a string table, and use LoadString.
This is good practise anyway - it means you can have different language resources, etc. Hard coded strings in your source is a Bad Idea (tm).
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
Hi,
I fixed the problem, and it seems I was right about the Unicode/ANSI umlauts. This code for example didn't produce a MessageBox:
std::wstring unicode = (wchar_t) 0xD6;
unicode += L"ffnen";
if (unicode == L"Öffnen")
::MessageBox(0, 0, 0, 0);
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Hi @ all,
under XP I have the problem sending UDP Packets over the sendto command.
Sporadically my client didn´t send the packets.
The first time it works fine. I build the packet and then send it with the sendto command. On the second time or more the packet will be created and runs the send command correct. The Remote Port and Address are correct too.
But if I protocol these actions with packetyzer or wireshark the sent packet is not displayed anywhere.
Anyone here who knows what it could be that the packet will not send?
Regards,
Karsten
|
|
|
|
|
Check the return value of sendto API
|
|
|
|
|
the return Value is above Zero and the size of command.
|
|
|
|
|
UDP will drop packets if you send them too fast - here's a Microsoft article that says as much[^].
Fundamentally, UDP makes no delivery guarantees, so if that's important to you, you either want to think about using TCP (that'd be my choice) or implementing some form of handshaking.
I would recommend downloading the IBM TCP/IP Redbook[^] - it's a very useful networking resource.
|
|
|
|
|
But under Vista it works correctly.
And I send SIP Packets above the UDP Socket.
I can´t use TCP because it´s a realtime ip phone I programm.
|
|
|
|
|
CrazyDogg wrote: But under Vista it works correctly.
Which means it's likely a coincidence.
CrazyDogg wrote: I can´t use TCP because it´s a realtime ip phone I programm.
Then it'll be up to you to code the handshaking.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
How to code a handshaking for this?
I have never done this.
|
|
|
|
|
CrazyDogg wrote: How to code a handshaking for this?
However you want to. It's just extra information (usually a CRC) that the send adds to the packet at a specific location (e.g., front, back). The receiver looks at that spot to know if all of the packet has been received. If so, an ACK of some sort is sent back.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|