|
Thank you!
The following change did the trick:
BadKarma wrote: CArbitraryClass& operator->() { return m_ArbitraryObject; }
to
CArbitraryClass* operator->() { return &m_ArbitraryObject; }
The compiler now automatically calls the second operator->() and everything looks like you have no temporary object! I tested this syntax on VS2005 and I don't know if it works on previous versions of visual studio. I'll try it as soon when I get my hands on one of those versions.
I first tried it with implicit casting, but this didn't work. I now have the solution thanks to you.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Hi, bob
If you mean invisible (like hide the class/object from the user) instead of transparent (don't care for the object class type), I may have a solution that works like you intended.
class CArbitraryClass
{
public:
void DoFoo() {}
};
class CInvisibleTemporary
{
public:
CInvisibleTemporary(void (CArbitraryClass::*pFunction)())
{
(m_ArbitraryObject.*pFunction)();
}
private:
CArbitraryClass m_ArbitraryObject;
};
class CWrapperClass
{
public:
void Call(void (CArbitraryClass::*p)())
{
CInvisibleTemporary::CInvisibleTemporary(p);
}
};
The way you need to call it is like this:
CWrapperClass Wrapper;
Wrapper.Call(CArbitraryClass::DoFoo);
The function Call does create a temporary object of the type CInvisibleTemporary. To this object the function that needs to be called is given via its constructor.
The 'invisible' temporary object doens't exist anymore after the 'Call', which frees the locked resoruces.
I hope that this may be a solution or at least sets you on route to one
codito ergo sum
|
|
|
|
|
how can you use a class to be a utility class of another class?? need help!! im quite stuck with this one
|
|
|
|
|
in many different ways ...
class MyClass
{
class MyUtilityClass
{
};
MyUtilityClass myUtilityClass;
};
class MyUtilityClass
{
};
class MyClass
{
MyUtilityClass myUtilityClass;
};
or something else ..
maybe if you give us a hint at what you want to achieve, we would be in better position to give you a better answer.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Hello,
If the class has a default constructor, the following approach works:
CSomeClassUtil
{
public:
static void DoFoo();
private:
static CSomeClass m_Class;
};
This will not work if the class you want to use has a constructor with parameters. The following modifications will have to be made:
CSomeClassUtil
{
public:
static void Initialize()
{ m_pClass = new CSomeClass( ); }
static void DoFoo();
private:
static CSomeClass* m_pClass;
};
With this method you have to do some initialization checking to protect yourself from using uninitialized pointers and initializing the same pointer more than once resulting in memory leaks.
If this solution is not what you are looking for, could you explain your goal more clear?
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Good day
For my application that deals with the scheduling routine i need some control
like we have in Outlook 2003 in Calendar menu:
The yellow one, with the horizontal line that shows the hour periods,
and the rectangles put on it with some text.
Have anybody done this, or know where i can find - please reply
Otherwise i have to design it from scratch
Great thanks,
Denis
P.S. reply to theden@yandex.ru
|
|
|
|
|
TheDen wrote: The yellow one, with the horizontal line that shows the hour periods,
and the rectangles put on it with some text.
There are a few of those floating around Codeproject.
Here is one that I found with a quick search DayView - An Outlook Like Appointment View[^]
DEBUGGING : Removing the needles from the haystack.
|
|
|
|
|
Can anybody tell how can i fine the number of hard drives and the drive letters associated with each drive in VC++? Also the size of each drive...
|
|
|
|
|
wasife wrote: Can anybody tell how can i fine the number of hard drives...
Use the Win32_DiskDrive WMI class.
wasife wrote: ...the drive letters associated with each drive...
Use GetLogicalDrives() .
wasife wrote: Also the size of each drive...
Use GetDiskFreeSpaceEx() .
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
You can use _getdrives() and others directories routines
Example of msdn
/* GETDRIVE.C illustrates drive functions including:
* _getdrive _chdrive _getdcwd
*/
#include <stdio.h>
#include <conio.h>
#include <direct.h>
#include <stdlib.h>
#include <ctype.h>
void main( void )
{
int ch, drive, curdrive;
static char path[_MAX_PATH];
/* Save current drive. */
curdrive = _getdrive();
printf( "Available drives are: \n" );
/* If we can switch to the drive, it exists. */
for( drive = 1; drive <= 26; drive++ )
if( !_chdrive( drive ) )
printf( "%c: ", drive + 'A' - 1 );
while( 1 )
{
printf( "\nType drive letter to check or ESC to quit: " );
ch = _getch();
if( ch == 27 )
break;
if( isalpha( ch ) )
_putch( ch );
if( _getdcwd( toupper( ch ) - 'A' + 1, path, _MAX_PATH ) != NULL )
printf( "\nCurrent directory on that drive is %s\n", path );
}
/* Restore original drive.*/
_chdrive( curdrive );
printf( "\n" );
}
Output
Available drives are:
A: B: C: L: M: O: U: V:
Type drive letter to check or ESC to quit: c
Current directory on that drive is C:\CODE
Type drive letter to check or ESC to quit: m
Current directory on that drive is M:\
Type drive letter to check or ESC to quit:
|
|
|
|
|
Hi yet again
I have an application that has a bar graph to indicate the recording volume of my soundcard. This makes use of the control of MIXERCONTROL_CONTROLTYPE_PEAKMETER to draw the meter (I am using CPeakMeter class written by Langis Pitre). I have just found, however, that my target machine's soundcard (Sound Blaster Live! 24-bit) doesnt have this control! AAAAAARRRRRGGGGGHHHHH!
Is there a way round this?
I have taken a look at "Multimedia PeakMeter Control By Ernest Laurentin", but can't work out how to link this into the microphone level from my sound card.
Any help will be greatly appreciated - I apologise for asking, but I am relatively new to VC++.
Mike
|
|
|
|
|
I develop a c++ programme and I need to call some functions of subversion, but I don't succeed in using the api, somebody would have examples to help me
|
|
|
|
|
Anehl wrote: ...functions of subversion...
What's this?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
In fact I need to use the api subversion to obtain the projects/directories tree in the repository and other functions of this kind
|
|
|
|
|
Anehl wrote: ...I need to use the api subversion...
Which is what? Please explain what this term is.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
SubVersion is a very good "new-ish" version control system.
it offers an API to let 3rd party application access the system.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Maximilien wrote: SubVersion is a very good "new-ish" version control system.
Thanks. Without the proper capitalization, it looked like any other noun.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
In the first one, excuse my english.
It seems to me that an API is an interface allowing to (re)use the code, so instead of reprogramming completely we can use this API to make the link between two codes.
|
|
|
|
|
David know what an API is. The question was regarding to the 'subversion' word.
Ok now concerning your problem, you say that you are unable to make it work. Ok, but could you be more specific ? It is really vague so it's really difficult to help you. Give as much detail (usefull details I mean ) as possible
-- modified at 10:03 Wednesday 19th October, 2005
|
|
|
|
|
Cedric Moonen wrote: David know what an API is.
...scrambles to put dictionary away...
Thanks, Cedric!
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
I make a gui which connects to sourcesafe or subversion database, and give directories/projects tree from the root of the repository, to allow then to select the wanted projects.
So, with subversion I manage to make nothing, I don't succeed in to compile the api, nor to use it
|
|
|
|
|
Subversion...??
What's this?
Please post your message in detail
so that one can understand the real situation
Try to put the code were there is a problem .
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
Perhaps you meant this reply for Anehl.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Subversion is a free/open-source version control system. That is, Subversion manages files and directories
over time. A tree of files is placed into a central repository. The repository is much like an ordinary
file server, except that it remembers every change ever made to your files and directories. This allows
you to recover older versions of your data, or examine the history of how your data changed.
|
|
|
|
|
Hello,
You might want to take a look at this[^]. It is an open source GUI application which does the thing you want to do. Maybe you can join the team or develop your own hybrid.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|