|
You can't construct to object in the class definition. What you have to do, is construct it in the constructor initialization list. In your cpp (or where your constructor is defined):
secClass::secClass() : obj1("abc")
{
}
|
|
|
|
|
Thanks a lot!! Problem solved.
|
|
|
|
|
Hello all..
I'm facing a problem regarding replacing string in _bstr_t type...
Say i've data in "bstr_Data" which is defined as
_bstr_t bstr_Data;
Now this data contain "#" in it.. I've to replace "#" with ";".. All the occurence..
How can i do it..
Thanks
|
|
|
|
|
You need to convert bstr to cstring and then use find method of it....
_bstr_t bstrStart(bstr);
CString s;
s.Format(_T("%s"), (LPCTSTR)bstrStart);
Thanks A Ton
Ash_VCPP
|
|
|
|
|
I forgot to tell it's WIN32... Will it work??
I mean CString??
|
|
|
|
|
it will work if u have taken mfc support while creating your project...
Thanks A Ton
Ash_VCPP
|
|
|
|
|
To use CString in Win32, include the file atlstr.h
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Including atlstr.h gives me lots of error... Isn't there any way to do with WIN32 functions only???
|
|
|
|
|
go to project menu select settings and from tab general select mfc support from the combo compile it n enjoy.....or include string.h file for ur purpose only.
Thanks A Ton
Ash_VCPP
|
|
|
|
|
Something base on the following?
#include "stdafx.h"
#include <string>
int _tmain(int argc, _TCHAR* argv[])
{
std::wstring str1;
str1 = L"abc#efg#ijk";
int found = str1.find_first_of(L"#");
while(found != str1.npos)
{
str1.replace(found, 1, L";");
found = str1.find_first_of(L"#",found+1);
}
return 0;
}
|
|
|
|
|
Yes that works..
Many thanks Jonathan...
|
|
|
|
|
One more question...
As i'm using _bstr_t.. So do i need to free it??
|
|
|
|
|
_bstr_t have destructors which free the internal string, so if its local the destructor will be called when it goes out of scope. If you created it using 'new' you have to delete it.
|
|
|
|
|
Right.. I'm not creating it using new...So i don't need to free it..
Cool..
Once again thanks Jonathan
|
|
|
|
|
One more question...
I'm giving something like this.
int found1 = wsVar.find_first_of(L"&&&&");
while(found1 != wsVar.npos)
{
wsVar.replace(found1, 1, L"\"");
found1 = wsVar.find_first_of(L"&&&&",found1+1);
}
So wherever it found one "&" it convert to ".. I need that whenever it found "&&&&" then only it replace with "(double quotes only)..
Is it possible???
Thanks
|
|
|
|
|
Hi All,
I am compiling my project in the release mode in VC++. I have a .def file where i have declared the setLog and now i am getting following error
Linking... Creating library Release/HKL.lib and object Release/HKL.exp HKL_libinterface.obj : error LNK2001: unresolved external symbol _SCTP_setLog@8
Please help me on the above to fix the problem.
Thanks
|
|
|
|
|
When the project was in Debug configuration perhaps you set the location of the library containing setlog in Project | Properties (but only in Debug config) and now it also needs setting in the properties for Release mode as well?
|
|
|
|
|
Hey can you tell me how to set this properties..
Thanks
|
|
|
|
|
Well I'm geussing this is the problem.
Have you managed to compile it in Debug mode?
|
|
|
|
|
yes i have compiled it in the debug mode..
and it is compiling fine in debug mode..
but when i compile in release mode i face this error which i mentioned
in my problem..
|
|
|
|
|
Depends on what version of Visual studio, but in 2008 its:
Project | Properties | Configuration Properties | Linker | General to see the Additional Library directories
and
Project | Properties | Configuration Properties | Linker | Input to see the Additional Dependancies
Look at these settings in Debug mode and then in Release mode, is there a setting in debug that is not in release?
|
|
|
|
|
|
How about WM_WINDOWPOSCHANGED[^]?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Hai!
I have a string pointer in my MFC application, a function assigns some strings to this pointer.
Now i want to extract the strings, i do it in following manner:
CString *strArray;
...
// Function call () that assigns some strings
...
// code to extract each string from the pointer
for (i = 0; strArray [i] != ""; i ++)
{
// i am extracting each string like strArray [i]
}
but the problem is when it comes to end of the pointer, assume that there are 4 strings, when the loop checks for 5 th string(which is not present), it gives an unhandeled exception error.
when i debbugged, strArray[5] was pointing to "Bad Pointer"
How to resolve this problem.
Is there any better way to extract each string from a string pointer?
Thanks!
|
|
|
|
|
If you don't know how many strings will be stored in your array, I suggest you use a dynamic container, like a std::vector for instance. It will make your life much easier when working with a dynamic array.
If you still want to stick to your solution, then you will need an extra variable which counts the number of strings in the array (and the array should be large enough also).
|
|
|
|