|
Sadly, MSDN doesn't have as much help as it used to, the MSDN that came with VC6 is probably your best bet, if you can get it.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
For Excel 2003, see C:\Program Files\Microsoft Office\OFFICE11\1033\VBAXL10.chm or C:\Program Files\Microsoft Visual Studio\MSDN\2001OCT\1033\VBAXL10.chm.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Right, well. I have a struct which so far contains just a char* and a vector of the struct.
Now, i have a function that adds a new item to my vector which takes a char* which is used to initialise my struct:
void AddItem(char* ItemName)
{
myStruct newItem(ItemName);
myVector.push_back(newItem);
}
In the struct constructor i used strcpy to copy the contents of the string rather than the pointer, and i also made a copy constructor which uses strcpy again when copying the struct.
But still, once we leave the function (or should i say, the function in which this function was called) the item, disappears. Debuging it i can see that the item is added and then once we get out of the functions simply vanishes, and i don't understand why.
So, any help of course, would be greatly appreciated.
My current favourite word is: Nipple!
-SK Genius
modified on Sunday, March 9, 2008 8:37 PM
|
|
|
|
|
AddItem() is just a global scoped function? Or is it a method of a class?
What, then, is myVector? What does the myStruct structure declaration look like?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
AddItem is a method of a class.
The whole structure is kind like this:
int main()
{
Class1 myClass;
Class2 myOtherClass;
Class2.DoStuff(myClass);
}
...
Class2::DoStuff(Class1 firstClass)
{
char* text = "SomeText";
firstClass.AddItem(text);
}
It is of course quite different, but its basically the same thing.
The struct looks kinda like this:
struct myStruct
{
public:
char* Name;
myStruct(char* name)
{
Name = new char[100];
strcpy(Name, name);
}
}
My current favourite word is: Nipple!
-SK Genius
|
|
|
|
|
SK Genius wrote: Class2::DoStuff(Class1 firstClass)
If you are really passing objects by value like that then the scope of
those objects only lasts for the DoStuff() call. After it returns, your original
objects remains untouched.
Maybe you meant to pass it by reference?
Class2::DoStuff(Class1 <font color="Red">&</font>firstClass)
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Its actually passed by a pointer... hmm. This is what really happens:
Class Object
{
virtual void DoAction(void** args);
}
Class Player : public Object
{
void AddItem(char* ItemName);
void SomeFunction();
}
Player::SomeFunction()
{
int dir = 5;
Object* myObj = GetObjectFromSomewhere();
void** temp = new void*[2];
temp[0] = &dir;
temp[1] = this;
}
Class NPC : public Object
{
void DoAction(void** args);
}
void NPC::DoAction(void** args)
{
int dir = *(int*)args[0];
Player player = *(Player*)args[1];
}
Then of course, i used the non-pointery player object to work on. Thats the problem isn't it?
The only reason i didn't just use the pointer was because i already had alot of code with just the player.stuff rather than player->stuff
I figured it would save time. I guess not.
Oh well, lesson learned.
My current favourite word is: Nipple!
-SK Genius
|
|
|
|
|
SK Genius wrote: i used the non-pointery player object to work on. Thats the problem isn't it?
On this line you mean?
Player player = *(Player*)args[1]; If so, then yes - you're working with a new Player object copied from the passed object...
Any changes made to the new object won't be reflected in the original.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi
I've written an application in VC++ newly and it worked well while being in debug mode. But when tring it in release version, I get an error message that says:
"An unsupported operation was attempted."
My app loads a dialog box from a DLL. After spending and wasting(!) a lot of time, I found the error occurs in "DoDataExchange" function in the following line:
"DDX_Control(pDX, IDC_DLL_EDIT_WRD, m_ctlWord);"
Please don't let my app to become waste!
Thanks...
|
|
|
|
|
And what was the error?
Moreover, I've you read here and here?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Because Control is not exist corresponding to IDC_DLL_EDIT_WRD ID.
|
|
|
|
|
Add a virtual function like clone() ?
-------------------------------------
How to write the copy constructor of class NeedCopyConstruct ,
NeedCopyConstruct::m_list might contain Base and Derived
pointers.
class Base
{
public:
Base(const Base &base);
}
class Derived : public Base
{
public:
Derived(const Derived &derived);
}
class NeedCopyConstruct
{
public:
NeedCopyConstruct(const NeedCopyConstruct &ncc);
CTypedPtrArray<cobarray,base*> m_list;
}</cobarray,base*>
modified on Sunday, March 9, 2008 11:54 AM
|
|
|
|
|
Exploit polymorphism: implement a virtual member, say clone (basically a copy-constructor), for both Base and Derived class and use it to copy list members.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
followait wrote: Add a virtual function like clone()?
I guess you modified to add the above, and you want some other method to call the copy constructor.
I assume, if m_list contains Base and derived pointers means your list holds a single type may be "Base *. I assume your base class destructor is virtual destructor other wise you end up not calling derived class destructor if it is derived object and pointer is base.
If you have any virtual function, possibly atleast virtual destructor, then you can use the runtime type information to call the copy constructor,
Base *pObj = new Derived();
Base *pObjClone = NULL;
const type_info& typeInfo = typeid(*pObj);
if (typeid(Derived) == typeInfo)
{
pObjClone = new Derived(( Derived & )*pObj);
}
else if (typeid(Base) == typeInfo)
{
pObjClone = new Base(( Base & )*pObj);
}
else
{
}
Note: if you don't have virtual destructor, deleting the list item may have memory leak.
this method can be used if your class have any virtual function and you don't want to change the code to add clone() method.
if you don't have virtual functions and don't want to add clone method, may be storing type (enumerated values) along with the pointer in the list, or separte list for each type can be used.
if you are free to add virtual functions, Clone() method will be the right choice.
|
|
|
|
|
How to make a standalone EXE(with all libraries included) file in Visual Studio 1998!
In Visual Studio 2005, there is an option but I can't find one in Visual Studio 1998!
Please help me out!
|
|
|
|
|
ddspliting wrote: Visual Studio 1998
Another custom version of Visual Studio!
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Project/Setting/General/Microsoft Foundation Classes: Use MFC in a Static Library
|
|
|
|
|
Its not working in Visual Studio 6(1998).It has only option of USE MFC in share DLL! and not static DLL unlike Visual Studio 2005!
Please if there is any other way???
|
|
|
|
|
You're wrong: Visual Studio 6 allows to link statically with MFC .
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
check option for the compiler? cl.exe
|
|
|
|
|
and where is tht compiler options?
|
|
|
|
|
I have a program which I adapted from Borland C++ to Visual C++ and got compiling correctly in Debug mode.
On changing to Release mode its linker moaned thus. On going back to Debug mode it compiled and linked successfully. What happened?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1>IMAGES.CPP
1>Compiling resources...
1>Microsoft (R) Windows (R) Resource Compiler Version 6.0.5724.0
1>Copyright (C) Microsoft Corporation. All rights reserved.
1>Linking...
1>IMAGES.obj : error LNK2001: unresolved external symbol _GdipGetImageEncodersSize@8
1>IMAGES.obj : error LNK2001: unresolved external symbol _GdipGetImageEncoders@12
1>IMAGES.obj : error LNK2001: unresolved external symbol _GdiplusStartup@12
1>IMAGES.obj : error LNK2001: unresolved external symbol _GdipCreateBitmapFromFile@8
1>IMAGES.obj : error LNK2001: unresolved external symbol _GdipCreateBitmapFromFileICM@8
1>IMAGES.obj : error LNK2001: unresolved external symbol _GdipFree@4
1>IMAGES.obj : error LNK2001: unresolved external symbol _GdipAlloc@4
1>IMAGES.obj : error LNK2001: unresolved external symbol _GdipCloneImage@8
1>IMAGES.obj : error LNK2001: unresolved external symbol _GdipDisposeImage@4
1>IMAGES.obj : error LNK2001: unresolved external symbol _GdipCreateHBITMAPFromBitmap@12
1>IMAGES.obj : error LNK2001: unresolved external symbol _GdipGetImageWidth@8
1>IMAGES.obj : error LNK2001: unresolved external symbol _GdipGetImageHeight@8
1>IMAGES.obj : error LNK2001: unresolved external symbol _GdiplusShutdown@4
1>IMAGES.obj : error LNK2001: unresolved external symbol _GdipCreateBitmapFromGdiDib@12
1>IMAGES.obj : error LNK2001: unresolved external symbol _EncoderQuality
1>IMAGES.obj : error LNK2001: unresolved external symbol _GdipSaveImageToFile@16
1>C:\2d\ppp_vc\Release\ppp_vc.exe : fatal error LNK1120: 16 unresolved externals
1>Build log was saved at "file://c:\2d\ppp_vc\ppp_vc\Release\BuildLog.htm"
1>ppp_vc - 17 error(s), 0 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
|
|
|
|
|
I think Gdiplus.lib is included to the project settings for debug configuration and not for release configuration. add to release config also,
or add to the common header the following, stdafx.h if using precompiled header.
#pragma comment (lib, "Gdiplus.lib")
|
|
|
|
|
Probably project properties for Debug build contain correctly gdiplus.lib as additional library to link, while for Release build it don't.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Hello everyone,
About Bjarne's statement in section C.13.8.3 Point of Instantiation Binding, I have made some further thinking and coding. Here are my two questions.
--------------------
Nor can an unqualified name used in a template ever be bound to a local name.
--------------------
1. Sometimes we use qualified name in template? I have never usage of qualified names in template. Does Bjarne means some code like this, Does such use rare?
(suppose Foo is a template class)
Foo<::myType> or Foo<Somenamespace::myType> or Foo<SomeClass::myType>
2,
Does Bjarne indicate qualified names used in a template coule be bound to a local name? For example, we define a local namespace, put a struct in the local namespace, then we could use localNameSpace::strctInLocalNameSpace to instantise the template?
Puesdu code like this.
void f()
{
namespace localns {
struct foo;
};
vector<localns::foo> vc;
}
thanks in advance,
George
|
|
|
|