|
Hmmm...you have a point there, I'll ask.
"Things are more like they are now than they ever were before."
-- Dwight Eisenhower
|
|
|
|
|
|
So, where is the managed code? Is everything unmanaged?
|
|
|
|
|
Hi im new to Managed C++
Can a anyone tell me how to convert String to int..
In native C++ we used atoi(CString) function.So in MC++ what should I use.
cheers,
Super
------------------------------------------
Too much of good is bad,mix some evil in it
|
|
|
|
|
If you're using .NET string and int datatypes (internally the String and Int32 classes) you can use the Parse method of Int32 :
int nResult = 0;
String* pMyNumber = "15";
nResult = Int32::Parse( pMyNumber );
I've found that it's possible to cast between the CString and the .NET String datatypes without any trouble (at least I think I did -- was a while ago I last used MC++).
If not, I'm sure someone far more knowledgeable than me will be able to suggest exactly what you need to do
--
Paul
"Put the key of despair into the lock of apathy. Turn the knob of mediocrity slowly and open the gates of despondency - welcome to a day in the average office."
- David Brent, from "The Office"
MS Messenger: paul@oobaloo.co.uk
|
|
|
|
|
Hello All,
I have a project in MC++ consisting of several components/controls.
Many parts used indexed properties. These are recognized in VB.NET as properties, and shows in the VB.NET code browser as such.
However, in C#, the indexed properties are seen as methods;
get_Item/set_Item instead of the Item property in the following:
__property String __gc* get_Item(Int32 index)
{
}
__property void set_Item(Int32 index, String __gc* value)
{
}
Is this a known problem? is there anyway to work around it? It is
becoming very difficult to document our components.
Best regards,
Paul.
Jesus Christ is LOVE! Please tell somebody.
|
|
|
|
|
Hi Paul
Put [ DefaultMember( "Item" ) ] before your class declaration
Regards,
Nish
p.s. I answered this in the newsgroup too (then saw this post and confirmed that you and he are the same )
p.s. #2 - I posted this here too so you'll find it earlier
"I'm a bit bored at the moment so I'm thinking about writing a new programming language" - Colin Davies
My book :- Summer Love and Some more Cricket [New Win]
Review by Shog9 Click here for review[NW]
|
|
|
|
|
Thanks.
Nishant S wrote:
p.s. I answered this in the newsgroup too (then saw this post and confirmed that you and he are the same )
Read that too. Andre claims it is a bug. It works with VB.NET without marking it as DefaultMember. I do not know when the MC++ team will have put a real working compiler for .NET - it is still too buggy
BTW, should it be DefaultMember or DefaultProperty?
Best regards,
Paul.
Jesus Christ is LOVE! Please tell somebody.
|
|
|
|
|
Paul Selormey wrote:
Andre claims it is a bug
Well, I did not say it is a bug. All I said was that
a) As DefaultMember makes the property in question the indexer for C# (e.g. public string this[int index]{get; set;} ), there can be only one indexed property in C#
b) The way the indexer is accessed (instance[5] instead of what on expect for a indexed property instance.MyProp[5]) makes the class look array-like.
So, after all, it is not a missing feature in MC++ (which supports indexed properties), but more of a missing feature in the C# specifications.
(BTW. it is System.Reflection.DefaultMemberAttribute)
Best regards,
Andre
P.S.: damn, i hate it when I have to rewrite the whole post just because I forgot to log in
|
|
|
|
|
When compiling and linking a MC++ 2003 class library, the /EHsc compiler option causes a
LNK2001 error when a class is derived from a base class containing a destructor! Remove the
/EHsc option and the code compiles and links with any problems.
Create a MC++.NET 2003 Class Library with the following:
// bd.h
#pragma once
using namespace System;
namespace Testing
{
public __gc class Base
{
public:
Base(void)
{
Console::WriteLine(S"Base::Ctor");
}
~Base(void)
{
Console::WriteLine(S"Base::Dtor");
}
virtual void FromtheBase(void)
{
Console::WriteLine(S"Base::FromtheBase");
}
};
public __gc class Derived : public Base
{
public:
Derived(void)
{
Console::WriteLine(S"Derived::Ctor");
}
};
}
C++ Command Line:
/Od /AI "C:\Projects2003\Test\LinkError\Debug" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D
"_WINDLL" /FD /EHsc /MTd /GS /Yu"stdafx.h" /Fp"Debug/bd.pch" /Fo"Debug/"
/Fd"Debug/vc70.pdb" /W3 /nologo /c /Zi /clr /TP /FU
"C:\WINNT\Microsoft.NET\Framework\v1.1.4322\mscorlib.dll" /FU
"C:\WINNT\Microsoft.NET\Framework\v1.1.4322\System.dll" /FU
"C:\WINNT\Microsoft.NET\Framework\v1.1.4322\System.Data.dll"
Additional Options: /Zl
Linker Command Line:
/OUT:"C:\Projects2003\Test\LinkError\Debug\bd.dll" /INCREMENTAL /NOLOGO /DLL /DEBUG
/ASSEMBLYDEBUG /PDB:"C:\Projects2003\Test\LinkError\Debug/bd.pdb" /FIXED:No nochkclr.obj
mscoree.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib
shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib "\Program
Files\Microsoft Visual Studio .NET 2003\Sdk\v1.1\Lib\mscoree.lib"
Additional options: /noentry
Error:
bd error LNK2001: unresolved external symbol "void __cdecl __CxxCallUnwindDtor(void
(__thiscall*)(void *),void *)" (?__CxxCallUnwindDtor@@$$J0YAXP6EXPAX@Z0@Z)
After doing a link with the /FORCE option, I noticed the following in ildasm in the derived
class ctor:
.method public specialname rtspecialname
instance void .ctor() cil managed
{
// Code size 32 (0x20)
.maxstack 2
IL_0000: ldarg.0
IL_0001: call instance void Testing.Base::.ctor()
.try
{
IL_0006: ldstr "Derived::Ctor"
IL_000b: call void [mscorlib]System.Console::WriteLine(string)
IL_0010: leave.s IL_001f
} // end .try
fault
{
IL_0012: ldftn instance void Testing.Base::__dtor()
IL_0018: ldarg.0
IL_0019: call void
modopt([mscorlib]System.Runtime.CompilerServices.CallConvCdecl) __CxxCallUnwindDtor(method
unmanaged thiscall void modopt([mscorlib]System.Runtime.CompilerServices.CallConvThiscall)
*(void*),
void*)
IL_001e: endfinally
} // end handler
IL_001f: ret
} // end of method Derived::.ctor
Since /NOENTRY is enabled, linkage to __CxxCallUnwindDtor and __DllMainCRTStartup@12 is
impossible. This leaves me with a some options while I wait for an answer from somebody:
1. Remove /EHsc with my fingers crossed. What are the side effects of doing this?
/EH{s|a}[c][-] specifies the model of exception handling to be used by the compiler
according to the Microsoft Visual C++.NET Language Reference.
2. Remove /NOENTRY and configure compile and link options like MC++ 2002. (Danger!)
3. Create a netmodule or assembly for the base class declaration to be reference by an assembly with the derived class declaration. (No way, more files to maintain)
4. Compile to .exe from .h and .cpp files. (very limiting, hard to maintain. Anti .NET!)
5. Mixed DLL Loading Problem Solution (Pain in the neck!)
Actually, I believe the solution deals with the disabling of /EHsc (/EHsc- or /GX-). /EHsc- is the default setting if you compile from the command line. You will need /EHsc only when you have unmanaged C++ unwinding exceptions. For example, if you use STL, /EHsc would be required, and the Mixed DLL Loading Problem solution applied.
|
|
|
|
|
Just turn it off for the "managed" files. And keep the rest as you want.
Hey leppie! Your "proof" seems brilliant and absurd at the same time. - Vikram Punathambekar 28 Apr '03
|
|
|
|
|
I just installed Visual Studio .NET 2002 a few months ago. I am using the C++ compiler almost exclusively for ATL, MFC, WTL and managed C++ apps. Why should I upgrade to Visual Studio .Net 2003? What REAL benefits do I get. My company has already rejected the .Net framework for now... So I only use the C++ compiler. Is the upgrade worth it?
Robert Greene
|
|
|
|
|
I upgraded due to the following:
1. The upgrade costs less than $30.
2. VC++ 2003 conforms more closely with the standard.
3. MC++ has been enhanced.
Of course, with any new product, there will be bugs!
|
|
|
|
|
If you ever need to program in MC++, you must upgrade. The VS.NET 2002 is too buggy to use - you will have frustrated as many things do not work as expected.
Also, there are some startup wizards to quickly generate codes for you similar to C#. It comes with .NET 1.1, which you will have to work to get it to work with VS.NET 2002.
Best regards,
Paul.
Jesus Christ is LOVE! Please tell somebody.
|
|
|
|
|
Hi Robert... We should make this information more clear. All our messaging always seems to get lost... There are a significant number of changes in the C++ compiler from 7.1 to 7.0. There are things like P4/Athlon optimizations, SSE/SSE2 extension support, better whole program optimization (link-time optimizations), a better /GS switch and far, far, far better C++ conformance. If your a huge user of templates and use features like partial specialization and partial ordering, CL 7.1 is a huge win.
There are some benefits to the IDE also
Please checkout
http://msdn.microsoft.com/vstudio/
The upgrade is 29$ and you get a free pocketpc while supplies last
Albert Ho
.NET Developer Evangelist
Microsoft - Norcal
|
|
|
|
|
I'm writing data to a file and then wanting to run notepad.exe to display the data to the user.(Saves creating my own display medium) I've done it before in a Borland using SHELLEXECUTEINFO, and have been trying _exec** in VC++.Net without success.
Can someone point me in the right direction to what I should be using in the .Net environment please. i.e. what keywords should I be searching on.
Your help appreciated!
Regards,
Chris
|
|
|
|
|
WinExec ("notepad.exe",1);
rgds,
jhaga
|
|
|
|
|
Thanks for your help.
I tried it in my app, but it wouldn't compile, 'error C2065: 'WinExec' : Undeclared identifier.
I couldn't find it in my help either, so searching the MS website for WinExec led me to the following:
"The WinExec function runs the specified application.
Note This function is provided only for compatibility with 16-bit Windows. Applications should use the CreateProcess function.
"
so I'll give the CreateProcess function a try.
|
|
|
|
|
You need to include this file
#include "windows.h"
jhaga
|
|
|
|
|
That will work but since he said MC++ app, I am assuming he wants to use MC++ to do it (i.e. managed code). The way to do this in managed code is to use the BCL class System::Diagnostics::Process class like this:
#using <mscorlib.dll>
#using <System.dll>
using namespace System;
using namespace System::Diagnostics;
int _tmain()
{
Process::Start("Notepad.exe");
return 0;
}
------------------------------
Sam Gentile
Microsoft .NET Consultant
•Web Site : http://www.samgentile.com/
•My O'Reilly Articles: http://www.oreillynet.com/pub/au/1070
• Read my .NET Web Blog! http://dotnetweblogs.com/sgentile/
• Come hear me speak at Win-Dev! http://butrain.bu.edu/windev/bios.asp
----------------------------
|
|
|
|
|
I am losing some of the code with HTML formatting:
#using <mscorlib.dll>
#using <System.dll>
using namespace System;
using namespace System::Diagnostics;
int _tmain()
{
Process::Start("Notepad.exe");
return 0;
}
------------------------------
Sam Gentile
Microsoft .NET Consultant
•Web Site : http://www.samgentile.com/
•My O'Reilly Articles: http://www.oreillynet.com/pub/au/1070
• Read my .NET Web Blog! http://dotnetweblogs.com/sgentile/
• Come hear me speak at Win-Dev! http://butrain.bu.edu/windev/bios.asp
----------------------------
|
|
|
|
|
Hi All, wondering if someone could take a look at the below function and give me any clues as to why the output shows nothing.
I've passed through a sentence (no more than 100 characters) called sentence, which was input by the user. I'm trying to take each word, alphabetize it, and display the number of characters for each.
Thanks for any help!
<br />
void countOfChars(char sentence[]) <br />
{<br />
char *words = strtok(sentence," ");<br />
char *alphaArray[maxWords], *swap;<br />
int wordCount=0;<br />
<br />
cout << "\n\nWORD\t\t" << "Characters" << endl;<br />
<br />
while (words!=NULL) {<br />
wordCount++;<br />
words = strtok(NULL, " ");<br />
}<br />
alphaArray[wordCount] = words;
for (int i=0; i<wordCount-1; i++) {<br />
for (int j=0; j<wordCount-1; j++) {<br />
if (alphaArray[i] > alphaArray[i+1])<br />
swap = alphaArray[i+1];
alphaArray[i+1]=alphaArray[i];<br />
alphaArray[i]=swap;<br />
}}<br />
for (int x=0; x<wordCount; x++) { <br />
cout << alphaArray[x] << "\t\t" << strlen(alphaArray[x]) << endl;<br />
words = strtok(NULL, " ");<br />
}<br />
cout << endl;<br />
}<br />
Sheshi
|
|
|
|
|
// bubbelsort.cpp : Test use only
// Warning. Pointer handling, memory allocation and strtok() are bad
#include "string.h"
#include <iostream.h>
void countOfChars(char sentence[]) ;
int main(int argc, char* argv[])
{
const int buf_size = 1000;
char sName[buf_size]="a one a two";
//cout << "\n Enter max 50 words <each max 20 chars>:" << endl;
//cin.getline(sName, buf_size); // get the input line
countOfChars(sName);
}
void countOfChars(char sentence[])
{
char *words = strtok(sentence," ");
char *alphaArray[101]; // max 100 words
char *swap=NULL;
int wordCount=0;
while (words!=NULL) { // fill array
alphaArray[wordCount]=words;
wordCount++;
words = strtok(NULL, " ");
}
for (int i=0; i<wordCount; i++) { // bubbelsort the pointers
for (int j=i+1; j<wordCount; j++) {
if (*alphaArray[i]>*alphaArray[j])
{
swap=alphaArray[i];
alphaArray[i] = alphaArray[j];
alphaArray[j]=swap;
}
}
}
cout << "\n\nWORD\t\t" << "Characters" << endl; // display
for (int x=0; x <wordCount ; x++) {
cout << alphaArray[x] << "\t\t" << strlen(alphaArray[x]) << endl;
}
}
|
|
|
|
|
What is "this" pointer exactly?
Basil
|
|
|
|
|
a pointer to the class in context.
Hey leppie! Your "proof" seems brilliant and absurd at the same time. - Vikram Punathambekar 28 Apr '03
|
|
|
|