|
I am porting my application which is developed in VC++ 6.0 to VC++ 7.0.
I got ambigous error when I am using
CString cstrTemp += "A";
I think CString class is modified in .net and It won't accept "+=" operator. What is the other alternative.
Thanks in advance.
|
|
|
|
|
Anonymous wrote:
CString cstrTemp += "A";
cstrTemp = "A" + what ? Get rid of the +, and use it only when the string you're trying to add to already exists.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Thanks.
Sorry for that error.
It is like this
CString strTemp = "Class";
strTemp += "A";
let me know how to solve this.
|
|
|
|
|
What's wrong with strTemp = strTemp + "A"; ?
Although I'll admit, it's a bit weird. What's the text of the error ?
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Should be:
CString str("A");
str += "B";
|
|
|
|
|
I have an unmanaged DLL,I want to convert this to a Managed code so that C# and VB can access the resulting managed DLL, we decided to use Managed Extensions for C++(MC++)
As i am facing difficulties in analyzing the concepts hidden with in MC++,i want to know as
1.how to take the existing unmanaged code and compile it to managed code, (with the /clr compiler switch and It Just Works (IJW) )
2.Also to write managed wrappers around unmanaged functions.
After going through articles this is what i have understood, but absolutely don't know whether it is right or wrong??
To create a blank solution in Visual Studio and add the following projects
1) Unmanaged (old dll)
2) Managed (dll written using MC++)
3) and finally the C# project which accesses this Managed project
If this is correct, then is it possible for me to
1) directly take my old MFC DLL and open it in Visual Studio
2) should i add the .cpp and .h files from old dll to the managed project
3) should the import library of old dll be added to linker dependancies in the managed project
if all the above mentioned steps are wrong then what are the detailed steps i am supposed to follow.Anybody please help me
thanks in advance
|
|
|
|
|
I'm not sure about with a dll, but for a regular project, I just made a copy of my project's entire folder (just for backup purposes) and opened the .dsw file from .Net. I think it tries to convert everything as best as it can, but I think you have to use pragma_push and pragma_pop macros for MessageBox() and new (and probably a few more that I may not have had in my program).
Who are all these people and what are they doing in my house?...Me in 30 years, inside a grocery store
My articles[^]
bdiamond
|
|
|
|
|
Hi,
I'm writing a designer for a component, this designer is written in managed c++ and it is linked to a native dll, when i try to inherit from this component to use the designer the visual studio designer view, show this error:
The designer could not be shown for this file because none of the classes within it can be designed. The designer inspected the following classes in the file: Class1 --- The base class 'GuiSystem.MGUIDialog' could not be loaded. Ensure the assembly has been referenced and compiled.
i think that this error because it can't find the designer dll the designer dll is linked to but i don't know how can i make it search for it in the correct path (the native dll is linked to other native dlls and they are all in the same folder with the manged designer dll).
thx
|
|
|
|
|
hi
I think it needs to reference the lib file for this dll. In that case you need to specify it in the Properties|Linker|Input|Additional dependencies for the project.
The dll needs to be in the debug/release folder, but this should get export automatically if the dependency for the projects are set correctly.
Hope this helps, but I could be wrong.
|
|
|
|
|
I'm trying to manipulate a string in a function and return the result in two subsequent arguements in the same call. Here is one version I've tried using de-referenced pointers.
In MFC I passed the 2nd and 3rd arguements in as references to the original CStrings and that worked fine.
The same approach does not work and regardless of how I do it, verb and arg in the calling function (decodeLine(..)) remain unchanged.
UInt32 verbArguement(String * line, String ** pVerb, String ** pArg)
{ // splits verb(args) into verb and (args)
int bracketPos;
String * verb = *pVerb;
String * arg = *pArg;
// pull off the word preceeding the (
bracketPos = line->IndexOf('(', 0);
if (bracketPos >= 0)
{
verb = line->Substring(0,bracketPos);
arg = line->Substring(bracketPos); // here verb == "hint" and arg == "(2,P)"
return 1;
}
else
{
fileReaderException * e = new fileReaderException(fileReaderException::ERR_NON_FILE);
throw e;
}
return 0;
}
// strLine == S"hint(2,P)"
Int32 decodeLine(String * strLine)
{
String * verb;
String * arg;
if (verbArguement(strLine, &verb, &arg))
{
// at this point verb == null and arg == null
}
}
It seems that Microsoft has done a cheap and dirty on the implementation of String, effectively making all methods constructors and letting the garbage collector clean up the mess. That is why the pass by reference approach did not work. It also seems that the semantics of pointers and de-referencing has also changed. I'm pretty sure that the above code would work in standard C++.
Does anyone have a solution?
|
|
|
|
|
|
I think it causes something to only be included once.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
also, I think it can only be used with certain versions of C++. I think it's better to use the
#ifndef SOMEVERYLONGSTRINGTHATSHOULDNOTBEASILYDUPLICATED
#define SOMEVERYLONGSTRINGTHATSHOULDNOTBEASILYDUPLICATED</code>
<code>#endif
Who are all these people and what are they doing in my house?...Me in 30 years, inside a grocery store
My articles[^]
bdiamond
|
|
|
|
|
can a binary tree be used to implement a parser for SQL statments??
if not, does anyone have any other ideas??
Thank you
|
|
|
|
|
Dear all,
I cannot quite understand the logic behind the notion of operator overloading.
I understand that creating a class, is like creating a new type, therefore we can overload some operators to work with that new type. For example:
Ratio& Ratio::operator=(const Ratio& r)
{
num = r.num;
den = r.den;
return *this;
} This example is absolutely comprehensible but I cannot understand how I have to think, visualize the things in order to implement operator overloading in the *, *= operator, or in the == for instance.
Consider the Ratio class as the following:
class Ratio
{
friend Ratio& operator*(const Ratio& x, const Ratio y);
public:
Ratio(int =0, int =1);
Ratio& operator=(const Ratio&);
Ratio& operator*=(const Ratio&);
private:
int num, den;
};
Here is the understanding problem:
Ratio operator*(const Ratio& x, const Ratio& y)
{
Ratio z(x.num*y.num, x.den*y.den);
return z;
}
Is this the only way to overload that operator in this example? How one has to think in order to writew the above code? What are the steps involved in order to write the above two lines of code? And secondly in the first example (operator=) the return type is a reference to the Ratio but in the second is not a reference. Why is not a reference. When should we use a reference and when not?
Please bare in mind that I understand the use of friend functions.
Thanks in advance for the help,
grscot
|
|
|
|
|
you have to consider what it means to multiply the two things together, and then impliment this in code. It's as simple as that.
BTW, you're posting in the managed C++ forum - why ?
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
I am new to Managed C++, How can i conver the System.String to wchar_t (Unsigned 16bit).
Regards,
Murali.
|
|
|
|
|
use object oriented char converter class (my own one). Email me I will send it to you.
Cheers
MK
cheers
MK
|
|
|
|
|
I want convert managed C++ System.String type to C style, char, tchar, _bstr types. How can i conver to un managed c++ types.
Please help..
Murali.
|
|
|
|
|
If you don't mind using CString, it can take a System::String in its ctor.
|
|
|
|
|
Hai
u can convert it using the InteropServices
const char* str=(const char*)(System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi("ManagedString")).ToPointer();
By
Anish
|
|
|
|
|
can someone help me with iterating through a map. i am using a tree layout and only using the outer edges. im at the very bottom of the map and i want to get back to the root.
for example a char tree:
c
/ \
b d
/ \
a e
lets say i start at e, and the key is e and value is d, how do i get back to c and stop there, the key and value are equal at c, and print everything out. thanks a bunch
|
|
|
|
|
How do you turn a map into a tree ? Is it a map of maps ?
In any case, you're in the managed C++ forum.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
its just a map, where the value points to its parent node, like a tree.
|
|
|
|
|
So it's not a std::map then ? Or am I missing something obvious ?
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|