|
Nishant S wrote:
But I was talking about managed arrays CG.
Well, I dunno to what degree they can interexist. Obviously you'd have no interop, but I see no point in interop unless you have a language that is actually vastly different to C++ to interop with.
And either way I thought it was worth pointing out that jagged arrays are not a new idea.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
Half the reason people switch away from VB is to find out what actually goes on.. and then like me they find out that they weren't quite as good as they thought - they've been nannied. - Alex, 13 June 2002
|
|
|
|
|
Christian Graus wrote:
And either way I thought it was worth pointing out that jagged arrays are not a new idea.
I know that. That's why I wonder why they left it out of the managed extensions. But I have got info that it will be included in the next release of the VC++ compiler
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
|
|
|
|
|
HI
I have just upgraded my application written in VC++ 6.0 to VC++.net. i am receiving errors in message map. the description of error is
error C2440: 'static_cast' : cannot convert from 'void (__thiscall CProjectView::* )(WPARAM,LPARAM)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)'
i am quite frustrated. Is anybody out there who understands what is the possible cause of this error.
|
|
|
|
|
|
I would like to open more than one Form at once and can't seem to do it. I have a base form and want to pop up a custom message box form on top of it when needed. Anyone have any ideas?
Thanks in advance,
|
|
|
|
|
dtamburin wrote:
I would like to open more than one Form at once
I guess you mean modeless forms. You can use Show() for that.
dtamburin wrote:
I have a base form and want to pop up a custom message box form on top of it when needed.
If you mean, you want a modal form you need to use ShowDialog() instead of Show()
Or you can use the MessageBox class
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
|
|
|
|
|
Hi! The .NET collection classes have me pissed off. Being a C++ kinda guy, I love linked lists and I find the dynamic arrays to be really inane. So, I'm creating my own linked list class. I'm having some trouble with the enumerator:
An IEnumerator interface to an IEnumerable object is valid so long as IEnumerable wasn't modified after IEnumerator was created. How do I let my IEnumerator class know that my IEnumerable was modified?
I don't want to use a DateTime/TimeSpan class. I was thinking of incrementing an integer everytime the list is modified and making that the hash code. the IEnumerator could store the hashcode when it was created and compare it to the current hashcode. However, with extensive use, this procedure may not work.
Any suggestions?
|
|
|
|
|
Refer to Nish's excellent article on implementing collections in MC++. He uses one possible solution (flag to say if it is modified).
James
"Java is free - and worth every penny." - Christian Graus
|
|
|
|
|
I've got a problem which I can't solve.
I want to have 2 classes and both of them to have a pointer to each other...
public __gc class a
{
public:
a::a()
{
m_b->bb();
}
int aa()
{
return 1;
}
private:
b* m_b;
};
public __gc class b
{
public:
b::b()
{
m_a->aa();
}
int bb()
{
return 1;
}
private:
a* m_a;
};
The code isn't able to compile.
One solution is to use Object* instead of b* in the class a but I'll have to move my declaration to a cpp file and cast the pointer every time I want to use it.
Mayby another solution?
43 68 65 65 72 73 2c
4d 69 63 68 61 65 6c
|
|
|
|
|
Can't you forward declare class b?
Jignesh
|
|
|
|
|
It won't compile too because class b has a field m_a of class a.
43 68 65 65 72 73 2c
4d 69 63 68 61 65 6c
|
|
|
|
|
Use __single_inheritance keyword!
This is an example:
public __gc class __single_inheritance b;
public __gc class a;
public __gc class a
{
public:
a::a(){}
public:
b* m_b;
System::String* stringInClassA;
};
public __gc class b
{
public:
b::b(){}
public:
a* m_a;
System::String* stringInClassB;
};
int _tmain(void)
{
a* A = new a();
b* B = new b();
A->stringInClassA = new String("This is string in class A");
B->stringInClassB = new String("This is string in class B");
A->m_b = B;
B->m_a = A;
Console::WriteLine(A->m_b->GetType()->ToString());
Console::WriteLine(B->m_a->GetType()->ToString());
Console::WriteLine("");
Console::WriteLine("from class A:");
Console::WriteLine(A->m_b->stringInClassB);
Console::WriteLine("");
Console::WriteLine("from class B:");
Console::WriteLine(B->m_a->stringInClassA);
int i = Console::Read ();
return 0;
}
The matrix has you
MP
Maciej Pirog
|
|
|
|
|
Ok, but try to call a bb function on the m_b instance in the a class contructor.
It won't compile.
Any other tips?
43 68 65 65 72 73 2c
4d 69 63 68 61 65 6c
|
|
|
|
|
Yoe'r right
But I've got an idea!
Put:
1st classes declarations
2nd classes definitions and functions declarations
3rd functions definitions
Example:
public __gc class __single_inheritance b;
public __gc class __single_inheritance a;
public __gc class a
{
public:
void AskClassBToWrite();
void WriteA();
b* m_b;
};
public __gc class b
{
public:
void AskClassAToWrite();
void WriteB();
a* m_a;
};
void a::WriteA()
{
Console::Write("WriteA function was called");
}
void a::AskClassBToWrite()
{
a::m_b->WriteB();
}
void b::WriteB()
{
Console::Write("WriteB function was called");
}
void b::AskClassAToWrite()
{
b::m_a->WriteA();
}
int _tmain(void)
{
a* A = new a();
b* B = new b();
A->m_b = B;
B->m_a = A;
A->AskClassBToWrite();
B->AskClassAToWrite();
Console::Read();
return 0;
}
This will work!
MP
Maciej Pirog
|
|
|
|
|
Thanks man.
It's working.
43 68 65 65 72 73 2c
4d 69 63 68 61 65 6c
|
|
|
|
|
If anyone would like to team up and try to win some golf balls , please get ahold of me. Competition Details
Email me at Soliant@Yahoo.com
Soliant
"Every man dies, not every man really lives"
- Braveheart
|
|
|
|
|
Hi,
I know it is a VC++ forum, but i really need help!!! Let's see my code first:
*****************************************************************************
void operation(int[], char[]);
void waitprocess(int);
void main(void)
{
int i, j;
static char buffer[BUFSIZE+10], X_value[5], message[BUFSIZE];
int f_des[2];
if (pipe(f_des) == -1)
{
perror("Pipe");
exit(2);
}
if (fork()==0)
{
}
else
{
for (j=1; j<=5; j++)
{
if (fork()==0)
{
static char temp[BUFSIZE];
sprintf(temp, "Thread %d", getpid());
operation(f_des, temp);
}
}
while (X>0)
{
close(f_des[1]);
if (read(f_des[0], message, BUFSIZE) != -1)
{
sprintf(buffer, " - X = %d \n", X);
strcat(message, buffer);
write(1, message, sizeof(message));
waitprocess(getpid());
X--;
}
else
{
printf("error");
}
}
}
}
****************************************************************************
I have to create 5 "threads" but using fork() because i have to use pipe() to communicate with "server". This program is doing that 5 "threads" are trying to decrement the global X until X=0. I use pipe as a mechanisam to protect this "critical section". I don't know whether i did it right or wrong. Please help me to check!!!
Also, I found that the output looks strange. The output is always in a pattern. For example, the output looks liked:
Thread 1001 - X = 20
Thread 1003 - X = 19
Thread 1002 - X = 18
Thread 1005 - X = 17
Thread 1004 - X = 16
Thread 1001 - X = 15
Thread 1003 - X = 14
Thread 1002 - X = 13
Thread 1005 - X = 12
Thread 1004 - X = 11
*
*
*
You can see the sequence is 1,3,2,5,4,1,3,2,5,4...etc. I think the output should be in random sequence. Why it's happened???
Thanks!!!!!
|
|
|
|
|
Hahahaha. You're an idiot.
|
|
|
|
|
David Wengier wrote:
Hahahaha. You're an idiot.
At first I thought that it was pretty rude. Now I understand what is going on. I think the guy is playing.
|
|
|
|
|
Rama Krishna wrote:
At first I thought that it was pretty rude
I think my reply was very rude.
|
|
|
|
|
Hi everybody!
I have a typical problem here. My application is a multithreaded one. In one of the cases, there are multiple threads which will be using a common buffer which is a member variable of a particular class. This buffer is also allocated memory by one of these threads and to be accessed by the other threads. I am getting a dbg_heap error as debug assertion. How do i go about solving this problem. Please help me out as this is very urgent. Thanx in advance.
regards,
sailesh
|
|
|
|
|
Use one of the synchronization classes to ensure that only one thread can access the thread at a time (or multiple threads can read; but they must be done before a write could be performed).
Look for the .NET Monitor and Mutex classes for more info (more are available but those two are off the top of my head).
James
|
|
|
|
|
But yes, we do intend to add this feature to a future version of the product and we are working very hard to make that the very first future version.
Ronald Laeremans
Visual C++ compiler and libraries team
Cool huh?
That was in response to a question by someone asking when MC++ will have a Windows Forms designer
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Buy it, read it and admire me
|
|
|
|
|
Great News!! I'm just getting in to MC++ and finding this a bit of pain.
Derek Lakin.
I wish I was what I thought I was when I wished I was what I am.
Salamander Software Ltd.
|
|
|
|
|
Derek Lakin wrote:
Great News!! I'm just getting in to MC++ and finding this a bit of pain.
Yeah. Now we won't have to waste 10 minutes to align a text box and a combo box on a form
Just drag/drop/size it. Cool!
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Buy it, read it and admire me
|
|
|
|