|
I want on variable to hold a shared_ptr object, and its type needs variable.
void * can be cast directly, but it's not a shared pointer.
Here is a way, but not so good:
struct ItemData {
int m_type;
shared_ptr<type1*> pType1;
shared_ptr<type2*> pType2;
}
system
|
|
|
|
|
I'm not sure I understood your question, but you can't cast a shared pointer. A shared pointer is not a pointer, it's just a class instance that wraps a pointer. However, you can retrieve the stored pointer (with get()) and cast the return value.
|
|
|
|
|
Hello every one !
Does back propagation algorithms works with values that are not between 0 and 1, or do I have to normalize them to implement them ?
Thank you.
|
|
|
|
|
Hi everyone.
I'm having a problem when I try to use a pointer in a program.
I have one class and I want to call its functions in Main.cpp.
Here is the header User.h
#ifndef USER_H
#define USER_H
#include<iostream>
(...)
#include"manager.h"
using namespace std;
class User
{
private:
string type_user;
list<Manager>available_manager_list;
public:
User(string);
~User();
User(const User & );
string get_type_user();
friend ostream& operator << (ostream&, const User& );
void add_manager_available(const Manager& );
void remove_manager(const Manager & );
Manager* select_manager_name(string name);
void save_manager(ofstream& );
};
#endif
In Main.cpp when I try to do:User * user; user->
Nothing appears in user-> ... IntelliSense "Expression on the left of . or -> has a type which could not be resolved"
Thanks.
"Failure is always an option."
|
|
|
|
|
Which version of Visual Studio?
Have you tried rebuilding the intellisense database
(close solution, delete the solution's .ncb file, open
the solution)?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
My version is Visual Studio C++ 9.0 2008 express.
I did what you told me to: "lose solution, delete the solution's .ncb file, open the solution" , and it worked. Thank You!
"Failure is always an option."
|
|
|
|
|
FrankMookie wrote: My version is Visual Studio C++ 9.0 2008 express.
I haven't had to do that yet on VS 2008.
Good to know it worked though!
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi All,
I have an application(dialog based) which will minimize to the system tray.This application will have only a single instance. I want this application to be restored(dialog is displayed) while the exe is tried to execute again.
I used the following code to limit the execution to one instance.
if(OpenMutex(MUTEX_ALL_ACCESS,FALSE,"Limit1"))
{
}
else
CreateMutex(NULL,TRUE,"QKeys");*/
Thanks in advance,
John.
|
|
|
|
|
emmmatty1 wrote: I want this application to be restored(dialog is displayed) while the exe is tried to execute again.
When that condition is detected, simply call ShowWindow(SW_RESTORE) followed by Shell_NotifyIcon(NIM_DELETE, ...) .
"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
|
|
|
|
|
Is there an easy way (using Visual Studio 2005) to port all of the settings in the project properties from "Debug" mode to "Release" mode without having to type in every single change one line at a time?
(Yes, I know the settings should have been typed in under "All Configurations" instead of "Debug" to begin with, but they weren't.)
|
|
|
|
|
I made use of copy-paste by loading the .vcproj file in a text editor to solve my issues, and I think I'm good to go now. Feel free to let me know if a command or utility for this kind of issue exists, anyway.
|
|
|
|
|
Hi in my application i am creating some folders(keys) under Hkey_LocalMachine using the RegCreateKeyEx() fucntion its working fine in xp and 98 operaign system but wheni use the same code for VISTA its nto creating in localmachine its going to current user by default..
Can anybosy suggest me the reason for this
Thanks in advance....
|
|
|
|
|
This is one of the protection mechanisms in Windows Vista. Unfortunately, I don't know if or how you can defeat it (or if you should even want to).
|
|
|
|
|
Something to do with the administrator credentials on VISTA machine... So are you logged on to the VISTA machine with admin privileges and thrn running your application
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Run the application as Administrator
Regards,
--Perspx
"The Blue Screen of Death, also known as The Blue Screen of Doom, the "Blue Screen of Fun", "Phatul Exception: The WRECKening" and "Windows Vista", is a multi award-winning game first developed in 1995 by Microsoft" - Uncyclopedia
Introduction to Object-Oriented JavaScript
|
|
|
|
|
You need to include a security section in your manifest file to prevent Registry and File Virtualization for your application (or have the user turn User Access Control [UAC] off).
I would recommend the manifest resource file with the security section since it allows you to use registry and file functions without getting false positives from virtualization. I use "AsInvoker" for user apps.
"Windows via C/C++, Fifth Edition" by Richter has some good information on dealing with Vista and using manifests correctly.
|
|
|
|
|
Can u please make it a bit clear in "turn off the User Access Control [UAC]"....
|
|
|
|
|
Why is it people always gravitate toward the option that I didn't recommend?
Turning off UAC is as simple as going to "control panel", "User Accounts", "Turn User Access Control on or off".
However, the system will keep reminding you eternally that your security settings leave you vulnerable. Turning off UAC is really only useful for a simple test to see if your programmatic behavior/problem is related to UAC. You should not design your application with the requirement that the user set their security settings in any particular fashion.
The Microsoft endorsed way of properly designing an application for UAC is to use a security manifest section in your manifest file/resource.
Windows Vista Application Development Requirements for User Account Control Compatibility[^]
Create and Embed an application manifest[^]
Certified for Logo Test Case[^]
|
|
|
|
|
I want to duplicate an object, knowing only a base object and the type_info
In following sample, with function DuplicateObject(.), I want to duplicate an object pVarA.
Does anybody have an idea ?
Best regards.
//*****************************************************
class classA
{
public :
classA( string MyComment)
{
_MyComment = MyComment;
}
string _MyComment;
};
//*****************************************************
class classB : public classA
{
public:
classB( string MyComment, string MyOtherComment)
: classA( MyComment)
{
_MyOtherComment = MyOtherComment;
}
string _MyOtherComment;
};
//*****************************************************
void DuplicateObject( classA *pVarA, const type_info& pType)
{
static_cast<ptype> *pVarB = new static_cast<ptype>( ""); // !!! problem
*pVarB = *pVarA; // !!! problem
}
//*****************************************************
void func()
{
// dupplicate object of same class (classic)
classA *pVarA1 = new classA( "hello world !");
classA *pVarA2 = new classA( "");
*pVarA2 = *pVarA1;
// dupplicate object of heritance (problem !!!)
classB *pVarB1 = new classB( "hello world !", "come on !");
DuplicateObject( pVarB1, typeid( pVarB1));
}
|
|
|
|
|
Please read the posting guidelines before posting (formating of your code).
Do you want to clone an existing object, is that right ? If that's what you want, why don't you simply provide a virtual virtual Clone function in the base class that you redefine for the child classes:
classA* classA::Clone()
{
return new classA(this);
}
classB* classB::Clone()
{
return new classB(this);
}
If your classes contains more than simple data (e.g. pointers) you will need to provide a copy constructor in order to adapt it to your need. Otherwise the Clone function will be enough.
|
|
|
|
|
Why not just provide a copy constructor and be done with it? I don't understand the need for a ::Close() function.
|
|
|
|
|
If you have polymorphic types in a container and want to duplicate them (or some of them), you don't know the exact type of the object. So, if you have a virtual Clone function, you can simply work with the base class and call the Clone function to have a duplicate of the correct type of your polymorphic object.
Of course, this is used in very specific cases only
Gary R. Wheeler wrote: ::Close() function
It's a Clone function
|
|
|
|
|
Okay, okay. It's only 4 keys away on the keyboard...
|
|
|
|
|
Cédric,
Thank you for your answer.
But I think it's more difficult.
classA is the base class for all my messages (objects exchange through mailslots).
classB, classC, etc have herited from classA (they are more sophisticated messages).
My function called "Duplicate" function is in reality a function to send a message of classB, C, etc to SEVERAL mailslots (several destination).
So, I want to "give" my sophisticated message reference with its type (which is typeid( xVar)) to my function, wich will do a loop in order to duplicate the given message as necessary as to send it to ALL the mailslots.
It's the destination thread which delete the object after processing.
So, I want to "clone" the object, but the parameter of the function is of type "classA" (which is common to all types), and the type is only known by TYPEID.
Is there a possibility to do that ?
Best regards
|
|
|
|
|
Ok,
Now I have understand the mechanism.
Only a small detail : all the Clone() methods needs to have the same return type. So it's necessary to cast the returned result :
class classB : public classA
{
//...
}
classA* classA::Clone()
{
return new classA(this);
}
classA* classB::Clone()
{
return (classA *) new classB(this);
}
Thank you.
|
|
|
|