|
I have following piece of code, which works in VC7 but not in VC6. Don't know what's the problem.
A.h
----
class A
{
private:
template[int N] //using sqare brackets as somehow while posting it ignores '<'
class B {
public:
B() {}
class C
{
public:
C() {}
C* GetSomething() const;
}; //end class C
}; //end class B
};//end class A
A.cpp
------
template[int N]
typename A::B[N]::C*
A::B[N]::C::GetSomething() {}
RP
|
|
|
|
|
Repost the code and tick on the "Ignore HTML..." tick box so it renders properly and also post the error message(s) you are getting from the compiler/linker
Also, it might be better to post in the C++/MFC section as your problem is not C++/CLI related
|
|
|
|
|
I think what you are trying to do is not supported in VC++ 6.
George
-- modified at 20:12 Thursday 9th November, 2006
|
|
|
|
|
OK, before I get started I need to point out that I have never coded anything in Managed C++ before so what I am about to ask may seem as simple as drinking water to you, however to me it seems like moving mountains
I need to convert a comma delimited String* into a UNICODE PTCHAR array, so far my code looks something like the following:
<br />
Char splitChar[] = {','};<br />
String* split[] = searchReturnFields->Split(splitChar);<br />
<br />
char* returnFields[1024];<br />
for(int n=0; n<1024; n++)<br />
{<br />
returnFields[n] = NULL;<br />
}<br />
<br />
System::Collections::IEnumerator* myEnum = split->GetEnumerator();<br />
int enumPos = 0;<br />
while (myEnum->MoveNext())<br />
{<br />
String* field = __try_cast<String*>(myEnum->Current);<br />
returnFields[enumPos] = (char*)(void*)Marshal::StringToHGlobalAnsi(field);<br />
enumPos++;<br />
}<br />
Now assuming my input (searchReturnFields) is "val1,val2,val3" this code seems to partially work. I end up with an array that looks something like this:
<br />
[0] 0x0023a878 "x¨#" char*<br />
[1] 0x0023a858 "val2" char*<br />
[2] 0x0023a868 "val3" char*<br />
[3] 0x00000000 null<br />
[4] 0x00000000 null<br />
..<br />
..<br />
[1023] 0x00000000 null<br />
As you can see array position 0 contains, using the technical term, weirdy characters. However it should contain "val1".
So the question is what is going wrong here??
Also, why can I not do the following:
<br />
....<br />
String* split[] = searchReturnFields->Split(splitChar);<br />
<br />
char* returnFields[split->Length];<br />
....<br />
or
<br />
....<br />
String* split[] = searchReturnFields->Split(splitChar);<br />
int arrSize = split->Length;<br />
char* returnFields[arrSize];<br />
....<br />
From what I have managed to work out I have to give the array initialisation a constant int value
|
|
|
|
|
MrEyes wrote: I have never coded anything in Managed C++
MrEyes wrote: From what I have managed to work out I have to give the array initialisation a constant int value
So you are not experienced in C++? Why are you doing this project?
led mike
|
|
|
|
|
Thank for the information, hopefully with that I will find a working solution
|
|
|
|
|
MrEyes wrote: Thank for the information
Umm those were "questions" intended on understanding what level of help you require.
led mike
|
|
|
|
|
I have to work with xml files but i am new with that.
so i want to know how can i perform read and write operation with xml file.
if any body have idea about the same please share with me.
thanks & regards
bankey.
|
|
|
|
|
The XmlDocument class represents the DOM ( Document Object Model ), used to read, write and manipulate XML files. XPATH is the thing you need to google and learn about, if you want to search for nodes in your file.
|
|
|
|
|
|
In C Language how can we do the following..
conversion of the (int) to char
conversion of the (int) to (unsigned char) ------------interger to unsigned char
conversion of the (int) to (unsigned char *) ----------------interger to unsigned char pointer
Thanks..
|
|
|
|
|
Do you mean C, or C++ ? Did you mean to ask in the managed C++ forum ?
int to char happens by itself, it is implicit.
int to unsigned char should also occur, but can also be cast.
you can't convert an int to an unsigned char *, you need to use the & to get the address of the int.
|
|
|
|
|
Thx.. In C language.Actually i m pretty new. if we have
int i;
unsigned char j;
unsigned char *k;
then how can we do that..
|
|
|
|
|
OK. You're totally in the wrong place, this is the C++/CLI forum. The Visual C++ forum is the place for this.
int i = 0;
unsigned char j = i; // I think this will work, if not, then unsigned char j = (unsigned char)i; will
unsigned char * k = &j; // Now, j and k are the same thing, changing one will also change the other, as they are the same variable.
|
|
|
|
|
I have something like this
char **name;
name = new char*[3];
for(int i=0;i<3;i++)
{
name[i] = new char[256];
}
now how to delete name for no memory leaks
can anybody help me
thanks
abhi
|
|
|
|
|
I believe its:
<br />
delete [] name;<br />
since you dynamically created an array of char pointers.
Also, you will also have to delete each created char[256] beforehand.
<br />
for (int i; i < 3; ++i)<br />
{<br />
delete [] name[i];<br />
}<br />
<br />
delete [] name;<br />
Geo
-- modified at 6:03 Thursday 9th November, 2006
|
|
|
|
|
if I have something like this
void foo
{
char **name;
name = new char*[3];
for(int i=0;i<3;i++)
{
name[i] = new char[256];
}
}
and iam creating three objects of foo like foo foo1[3];
is the following is code?
for(int j =0;j<3;j++)
{
for (int i; i < 3; ++i)
{
delete [j] name[i];
}
delete [j] name;
}
if not then how to delete name
help me
thanks
abhi
abhi
|
|
|
|
|
First of all, foo looks like a function and not a class. So, you may need to find a good C++ Primer.
Memory management, especially with pointer-to-pointers, requires the programmer's special attention. Unless you are coding some performance critical code, STL would be a better route to go than to write "error prone" code with a limited knowledge of pointers and dynamic memory allocation.
See: http://www.codeproject.com/cpp/PointerArticle.asp[^]
void foo()
{
char **name;
name = new char*[3];
<br>
for (int i = 0; i < 3; ++i)
{
name[i] = new char[256];
}
<br>
<br>
for (int i = 0; i < 3; ++i)
{
delete [] name[i];
}
<br>
delete [] name;
}
Your code:
abhiramsss wrote:
if I have something like this
void foo
{
char **name;
name = new char*[3];
<br>
for(int i = 0; i < 3; i++)
{
name[i] = new char[256];
}
}
and iam creating three objects of foo like foo foo1[3];
is the following is code?
for(int j =0; j < 3; j++)
{
for (int i; i < 3; ++i)
{
delete [j] name[i];
}
<br>
delete [j] name;
}
if not then how to delete name
-- modified at 22:18 Thursday 9th November, 2006
|
|
|
|
|
I am putting together something and I need to get a list of active windows and the window that is on top, or in focus. How exactly could I go about this? I would imagine there is a specific function to call to for this. Does anyone know what it might be?
-- modified at 14:26 Tuesday 7th November, 2006
|
|
|
|
|
Did you want to do this in C++/CLI (.NET), or did you ask in the wrong forum ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Well I wanted to do it in C++ but if this C++/CLI is actually .NET then never mind. I suppose I should move it to Visual C++/MFC?
|
|
|
|
|
Yes.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I know how to read string values from Access db,
like:
CString strFields[5];
COleVariant varstring
for(field=0; field<5;field++)
{
recordset.GetFieldValue(field, varstring);
strFields[field]=V_BSTRT(&varstring);
}
then the string value from db. goes into strFields
But what if I know the strFields, and want write to update the db.
Does anyone know the adverse procedure?
|
|
|
|
|
This has nothing to do with "managed" development and you cross posted it into 3 forums and that subject is covered in several articles here on CodeProject. So to sum up.... stop posting garbage and do some work.
led mike
|
|
|
|
|
hi all!
I'd like to use Secure CRT memcpy_s(params); instead of old non-secure memcpy( params );
How to use it? where can I get all the necessary headers (and libs?) to use secure CRT in my proj?
thanks in advance,
d.coder
ps:
I use Microsoft Visual C++ .NET (develppment environment 2003 version 7.1.3088)
I've read about Secure CRT in this article:
"Employ Secure CRT Functions in Your C/C++ Applications"
http://www.codeguru.com/csharp/csharp/cs_misc/security/article.php/c11205/
|
|
|
|