|
Roger Stoltz wrote: it cannot be a virtual function since the virtual table goes with the instance of the object
Ya you are correct. thanks for pointing...
|
|
|
|
|
manjunath k reddy wrote:
class abc
{
public:
abc()
{
}
void disp()
{
}
};
int main()
{
abc *c = 0;
c->disp();
return 0;
} here for c is memory allocated. and can i access class methods from c.
No!
There is no memory allocated for 'c'. The variable 'c' is a pointer to an object of 'abc'-type and you've assigned NULL to that pointer.
If you will try to execute the code above you will get a runtime error saying "access violation" in your face.
The question you're asking, for the second time(!) even though you've already got an answer, makes no sense.
It suggests that you have no clue about the concept of object oriented analysis/design/programming.
Consider the following analogy:
- "I want to change tyres on my car. How do I do that?"
- "What kind of car do you have?"
- "I don't have a car."
- "????"
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
100% you will be get error wheres your memory allocated for c in this code you have a pointer without any instance of object and you want to use of a null pointer?
|
|
|
|
|
|
You've posted a similar question before and my answer is similar to the already given one:
You really need a good C++ tutorial.
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
[My articles]
|
|
|
|
|
Does anyone know how I got the oleauto.h version that only defined this function as taking 3 parameters?
STDAPI VarBstrCmp(BSTR bstrLeft, BSTR bstrRight, LCID lcid);
I also got errors for...
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlbase.h(4497) : error C2660: 'VarCmp' : function does not take 3 parameters
I recently had my machine rebuild and have installed VS6 & SP6.
modified on Tuesday, October 14, 2008 1:49 AM
|
|
|
|
|
lee23 wrote: Does anyone know how I got the oleauto.h version that only defined this function as taking 3 parameters?
STDAPI VarBstrCmp(BSTR bstrLeft, BSTR bstrRight, LCID lcid);
Google knows: http://www.codeproject.com/script/Forums/View.aspx?fid=1857&msg=49323[^].
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
[My articles]
|
|
|
|
|
This article you pointed me to indicates this is pre service pack 3 of Visual Studio. I have installed SP6. I wouldn't want to fix the problem by modifying the file but rather find out why I've got those files instead of the correct ones I need.
|
|
|
|
|
lee23 wrote: I have installed SP6. I wouldn't want to fix the problem by modifying the file but rather find out why I've got those files instead of the correct ones I need
That's good. Possibly you have to change the search order of Visual Studio include directories.
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
[My articles]
|
|
|
|
|
Hi all,
I need your help in my code I got from the gsoap article of Dr. Luigi here is his code:
CString CMyCurrencyConvertor::GetSoapError()
{
struct soap *pSoap = m_pCurrencyConvertor->soap;
CString sError;
if (soap_check_state(pSoap ))
sError.Format("Error: soap struct not initialized\n");
else
{
if (pSoap->error)
{
const char *pFaultCode, *pFaultSubCode = NULL, *pFalutString,
**iFaultCode;
iFaultCode = soap_faultcode(pSoap );
if (!*iFaultCode)
soap_set_fault(pSoap );
pFaultCode = *iFaultCode;
if (pSoap ->version == 2)
pFaultSubCode = *soap_faultsubcode(pSoap );
pFalutString = *soap_faultstring(pSoap );
iFaultCode = soap_faultdetail(pSoap );
sError.Format("%s%d fault: %s [%s]\"%s\"Detail: %s",
pSoap->version ? "SOAP 1." :\
"Error ", pSoap->version ? (int)pSoap->version : pSoap->error,
pFaultCode, \
pFaultSubCode ? pFaultSubCode : "no subcode",
pFalutString ? pFalutString : "[no reason]", \
iFaultCode && *iFaultCode ? *iFaultCode : "[no detail]");
}
}
return sError;
}
Now as per his advise is used MultiBytetoWideChar as the sError being returned is in japanese/chinese.
I modified his code into this:
sError.Format(_T("%s%d fault: %s [%s]\"%s\"Detail: %s"),
pSoap->version ? "SOAP 1." :\
"Error ", pSoap->version ? (int)pSoap->version : pSoap->error,
pFaultCode, \
pFaultSubCode ? pFaultSubCode : "no subcode",
pFalutString ? pFalutString : "[no reason]", \
iFaultCode && *iFaultCode ? *iFaultCode : "[no detail]");
MultiByteToWideChar( CP_ACP, 0, CT2A(sError),
strlen(CT2A(sError))+1, wszFaultString,
sizeof(wszFaultString)/sizeof(wszFaultString[0]) );
Now my problem is that once it is converted instead of the words i am expecting i get question marks example is
fault: ????? but it should be fault: host not found.
What should I do?
Thanks,
Jayjay
|
|
|
|
|
You have a few diagnostic tools...
Try putting wszFaultString,su into the watch window to see the wide string. (I assuming you are debugging this line by line? If not, don't come back until you have)
Also, you can view each unicode character individually, and see if the characters are being converted accurately (compare contrast with charmap) and visual studio is just having japanese font rendering problems, or even your app is displaying the text in a font that is missing those characters...
You're not checking the response from MultiByteToWideChar - are you sure it is succeeding?
What's with the CTO2A macro? If you're doing an explicit conversion, shouldn't you handle it yourself? That way you can see the intermediate results...
Good luck,
Iain.
|
|
|
|
|
So I am still relatively new to coding, so bear with me if I'm missing something obvious. I am trying to write software using the GP3 board by AWC with Visual Studio 2008. I received a package with the .h, .lib, and .dll files with it. I include them all in the same directory as my project, and tell it to include the .h file in the preprocessor. But when it loads the header file, I get tons of errors...including alot of syntax. Here is the basic layout of the header file.
#ifndef __GP3_HEADER_AWC
#define __GP3_HEADER_AWC
extern "C" {
__declspec(dllimport) HANDLE __stdcall GP3OpenCom(int port);
__declspec(dllimport) void __stdcall GP3CloseCom(HANDLE);
__declspec(dllimport) void __stdcall GP3SetLED(HANDLE h,BOOL state);
__declspec(dllimport) void __stdcall GP3SetTRIS(HANDLE h,int tris);
} #endif
Is this header file messed up, or am I just not doing something else right?
|
|
|
|
|
gargeug wrote: and tell it to include the .h file in the preprocessor
What do you mean by that?
You should use
#include "theheader.h"
in your source modules that need to use anything declared in the .h file.
gargeug wrote: I received a package with the .h, .lib, and .dll files with it. I include them all in the same directory as my project
The DLL should be in the same folder as your app's EXE file, or
anywhere else in the DLL search order[^].
You'll also need to add the .lib file to the list of import libraries
in your project settings. See
Project properties/Configuration properties/Linker/Input/Additional Dependencies
(.lib file names are separated by spaces)
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
gargeug wrote: But when it loads the header file, I get tons of errors...including alot of syntax.
For instance? Could you report, please, at least one of such errors?
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
[My articles]
|
|
|
|
|
here are examples of the errors I get
1>c:\documents and settings\administrator\my documents\geno\programs\gp3\gp3\gp3.h(5) : error C2143: syntax error : missing ';' before '__stdcall'
1>c:\documents and settings\administrator\my documents\geno\programs\gp3\gp3\gp3.h(5) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\documents and settings\administrator\my documents\geno\programs\gp3\gp3\gp3.h(5) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\documents and settings\administrator\my documents\geno\programs\gp3\gp3\gp3.h(6) : warning C4229: anachronism used : modifiers on data are ignored
1>c:\documents and settings\administrator\my documents\geno\programs\gp3\gp3\gp3.h(6) : error C2182: 'GP3CloseCom' : illegal use of type 'void'
1>c:\documents and settings\administrator\my documents\geno\programs\gp3\gp3\gp3.h(6) : error C2491: 'GP3CloseCom' : definition of dllimport data not allowed
1>c:\documents and settings\administrator\my documents\geno\programs\gp3\gp3\gp3.h(7) : error C2146: syntax error : missing ')' before identifier 'h'
1>c:\documents and settings\administrator\my documents\geno\programs\gp3\gp3\gp3.h(7) : warning C4229: anachronism used : modifiers on data are ignored
1>c:\documents and settings\administrator\my documents\geno\programs\gp3\gp3\gp3.h(7) : error C2182: 'GP3SetLED' : illegal use of type 'void'
1>c:\documents and settings\administrator\my documents\geno\programs\gp3\gp3\gp3.h(7) : error C2491: 'GP3SetLED' : definition of dllimport data not allowed
1>c:\documents and settings\administrator\my documents\geno\programs\gp3\gp3\gp3.h(7) : error C2059: syntax error : ')'
1>c:\documents and settings\administrator\my documents\geno\programs\gp3\gp3\gp3.h(8) : error C2146: syntax error : missing ')' before identifier 'h'
1>c:\documents and settings\administrator\my documents\geno\programs\gp3\gp3\gp3.h(8) : warning C4229: anachronism used : modifiers on data are ignored
1>c:\documents and settings\administrator\my documents\geno\programs\gp3\gp3\gp3.h(8) : error C2182: 'GP3SetTRIS' : illegal use of type 'void'
1>c:\documents and settings\administrator\my documents\geno\programs\gp3\gp3\gp3.h(8) : error C2491: 'GP3SetTRIS' : definition of dllimport data not allowed
1>c:\documents and settings\administrator\my documents\geno\programs\gp3\gp3\gp3.h(8) : error C2059: syntax error : ')'
|
|
|
|
|
Is there a in-built method to launch a EULA or a Disclaimer Dialogue and have a user accept it in Setup Wizard?
i.e. if a user was installing a application the first step would be to launch the EULA/Disclaimer Dialogue and accept it?
Cheers
Ranga
|
|
|
|
|
Polite answer: I don't believe so.
Longer answer:
That depends on the setup wizard you are using. There are many nice apps out there (I just made an setup program for my main app with Innosetup in about 5 mins two weeks ago) - and then your question is better aimed at their forums.
If you are creating your own setup wizard, then write the damn code. It's only a property page with a long read only edit control, an "I've read it" checkbox, and enabling / disabling a "Next" button on the parent sheet. If you can write an app worth installing, this probably isn't too hard. And that will be writable in less time than the delay between your question and my answer.
The actual EULA (aka All your base are belong to us) will be the longest part, but would have to be written anyway.
Iain.
[edited to correct spelling error]
|
|
|
|
|
Well all in all the reply from Iain was useful... it lead me to see what Innosetup is, and of course it is an excellent little tool which has a comprehensive Help and FAQ. Hats off to Jordan Russell.
I guess for people not familiar with writing scripts, it might take a bit of browsing around or using help, but the app itself has some good examples.
Ok, Just to answer my own question for those folks who write an App worth Installing and not in a position to write the "Damn Code" for a PP built in........
and have questions about adding a EULA or Disclaimer for the end user to accept,
You have to write a simple script. I did it with Innosetup and for the Eula to pop-up when the Setup/Installer launches used the line....
LicenseFile=eula.txt; in the [Setup] section.
Cheers
R
|
|
|
|
|
Hi all,
I'm trying to do a map of lists and I have problem, the program crush istantly, when I try to access an element of one of the lists in the map in order to insert or read an element in a list.
map<string,list><celement*>*> m_Layer;
list<celement*>* ElementList = new list<celement*>;
string layerName = "Hello";
pair<string,list><celement*>*> entry = pair<string,list><celement*>*>(layerName,ElementList);
m_Layers.insert(entry);
string s = "Hello";
list<celement*>* lista =m_Layers[s];
lista->push_back(m_pTempElement);
map<string,list><celement*>*>::iterator mapIter;
for(mapIter = m_Layers.begin();mapIter != m_Layers.end(); mapIter++)
{
list<celement*>* lista = mapIter->second;
list<celement*>::iterator iter;
for(iter=lista->begin();iter != lista->end();iter++)
{
...
}
}
Could anyone help me to find where I am making a mistake?
|
|
|
|
|
Laan82 wrote: ...the program crush istantly...
Which means what? Have you used the debugger to pinpoint which statement is in error?
Laan82 wrote: map<string,list><celement*>*> m_Layer;
Does this even compile? It is missing a bracket.
"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
|
|
|
|
|
Yes, in error are the iteration statement and the insert statement but I'm not capable of find the reason of this problem...
modified on Monday, October 13, 2008 2:16 PM
|
|
|
|
|
I think that the problem is with the way you are declaring the map on line 1. It should look like:
map
<
string,
list<celement*>
> *m_Layer;
You have an extra bracket and the list is not being correctly defined; you have to tell a template object what kind of object it is using at the time of declaration. If you make this change on line 1, 4, and 11 it should work. Just make sure that the <celement> phrase immediately follows the std::list declarator.
|
|
|
|
|
Hi experts:
I have a MFC Extension DLL module, say EXT.DLL, and I have Wrapper.exe which do LoadLibrary(TEXT("EXT.DLL")); So far everything is working.
However, a couple days ago, I started to integrate a third party library, Tool.lib, which export a method called myTool(char *).
My first step was, wrote a program, test.exe, which links Tool.lib, include Tool.h header file and call myTool(...) in test.exe, it works fine, I got what I want.
Then I did the same thing to EXT.DLL, link the Tool.lib, include Too.h and call myTool(...). It compiled EXE.DLL successfully. However, it failed in Wrapper.exe at LoadLibrary(TEXT("EXT.DLL"));
Any suggestion will be highly appreciated.
Thanks
Software Developer.
|
|
|
|
|
Debug your application.
Put a breakpoint at the statement where you're calling LoadLibrary() and execute that statement. Add the "@ERR,hr" symbol to the watch window as this will display the description for the last error in the calling thread's context.
It will probably show "File not found." or similar after you've called LoadLibrary().....
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Thanks Roger.
The "ERR, hr" shows "The specified module could not be found." as you suggested.
Below is the Output message:
'Wrapper.exe': Loaded 'C:\Data\Feb252008\New_Agent\EXT\DLL\Wrapper.exe', Symbols loaded.
'Wrapper.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll', No symbols loaded.
'Wrapper.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll', No symbols loaded.
'Wrapper.exe': Loaded 'C:\WINDOWS\system32\user32.dll', No symbols loaded.
'Wrapper.exe': Loaded 'C:\WINDOWS\system32\gdi32.dll', No symbols loaded.
'Wrapper.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC80.DebugMFC_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_c8452471\mfc80ud.dll', Symbols loaded.
'Wrapper.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC80.DebugCRT_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_f75eb16c\msvcr80d.dll', Symbols loaded.
'Wrapper.exe': Loaded 'C:\WINDOWS\system32\msvcrt.dll', No symbols loaded.
'Wrapper.exe': Loaded 'C:\WINDOWS\system32\shlwapi.dll', No symbols loaded.
'Wrapper.exe': Loaded 'C:\WINDOWS\system32\advapi32.dll', No symbols loaded.
'Wrapper.exe': Loaded 'C:\WINDOWS\system32\rpcrt4.dll', No symbols loaded.
'Wrapper.exe': Loaded 'C:\WINDOWS\system32\secur32.dll', No symbols loaded.
'Wrapper.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.5512_x-ww_35d4ce83\comctl32.dll', No symbols loaded.
'Wrapper.exe': Loaded 'C:\WINDOWS\system32\oleaut32.dll', No symbols loaded.
'Wrapper.exe': Loaded 'C:\WINDOWS\system32\ole32.dll', No symbols loaded.
'Wrapper.exe': Loaded 'C:\WINDOWS\system32\imm32.dll', No symbols loaded.
'Wrapper.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC80.MFCLOC_1fc8b3b9a1e18e3b_8.0.50727.762_x-ww_91481303\mfc80ENU.dll', Binary was not built with debug information.
'Wrapper.exe': Loaded 'C:\Data\Feb252008\New_Agent\EXT\DLL\RemoteInventoryD.DLL', Symbols loaded.
'Wrapper.exe': Loaded 'C:\WINDOWS\system32\version.dll', No symbols loaded.
'Wrapper.exe': Loaded 'C:\WINDOWS\system32\netapi32.dll', No symbols loaded.
'Wrapper.exe': Unloaded 'C:\Data\Feb252008\New_Agent\EXT\DLL\EXT.DLL'
'Wrapper.exe': Unloaded 'C:\WINDOWS\system32\netapi32.dll'
'Wrapper.exe': Unloaded 'C:\WINDOWS\system32\version.dll'
My guess is somehow, it unloaded DLL, as
'Wrapper.exe': Unloaded 'C:\Data\Feb252008\New_Agent\EXT\DLL\EXT.DLL'.
If I took out the following line:
FileHandle = ConvertFile( filename ) from EXT.DLL, Then everything is fine.
@ERR, hr return S_OK and below is the Output:
'Wrapper.exe': Loaded 'C:\Data\Feb252008\New_Agent\EXT\DLL\Wrapper.exe', Symbols loaded.
'Wrapper.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll', No symbols loaded.
'Wrapper.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll', No symbols loaded.
'Wrapper.exe': Loaded 'C:\WINDOWS\system32\user32.dll', No symbols loaded.
'Wrapper.exe': Loaded 'C:\WINDOWS\system32\gdi32.dll', No symbols loaded.
'Wrapper.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC80.DebugMFC_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_c8452471\mfc80ud.dll', Symbols loaded.
'Wrapper.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC80.DebugCRT_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_f75eb16c\msvcr80d.dll', Symbols loaded.
'Wrapper.exe': Loaded 'C:\WINDOWS\system32\msvcrt.dll', No symbols loaded.
'Wrapper.exe': Loaded 'C:\WINDOWS\system32\shlwapi.dll', No symbols loaded.
'Wrapper.exe': Loaded 'C:\WINDOWS\system32\advapi32.dll', No symbols loaded.
'Wrapper.exe': Loaded 'C:\WINDOWS\system32\rpcrt4.dll', No symbols loaded.
'Wrapper.exe': Loaded 'C:\WINDOWS\system32\secur32.dll', No symbols loaded.
'Wrapper.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.5512_x-ww_35d4ce83\comctl32.dll', No symbols loaded.
'Wrapper.exe': Loaded 'C:\WINDOWS\system32\oleaut32.dll', No symbols loaded.
'Wrapper.exe': Loaded 'C:\WINDOWS\system32\ole32.dll', No symbols loaded.
'Wrapper.exe': Loaded 'C:\WINDOWS\system32\imm32.dll', No symbols loaded.
'Wrapper.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC80.MFCLOC_1fc8b3b9a1e18e3b_8.0.50727.762_x-ww_91481303\mfc80ENU.dll', Binary was not built with debug information.
'Wrapper.exe': Loaded 'C:\Data\Feb252008\New_Agent\EXT\DLL\EXT.DLL', Symbols loaded.
'Wrapper.exe': Loaded 'C:\WINDOWS\system32\version.dll', No symbols loaded.
'Wrapper.exe': Loaded 'C:\WINDOWS\system32\netapi32.dll', No symbols loaded.
'Wrapper.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC80.DebugMFC_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_c8452471\mfc80d.dll', Symbols loaded.
EXT.DLL Initializing!
As I said before, EXT.dll linked w/ 3rd party lib, which exports FileHandle = ConvertFile( filename ) method.
Thanks a lot in advance for your help.
Developer
|
|
|
|
|