|
Sorry I probably didn't phrase my question propperly. Class A is already declared in ClassA.h with it's header etc, however, I want to use it in ClassB.
I think I'm asking the same question as 'Simple question about header files'
http://www.thecodeproject.com/script/comments/forums.asp?forumid=3785&select=1423769#xx1424478xx[^]
<br />
ClassA.h<br />
<br />
#include "classB.h"<br />
<br />
public __gc class A {<br />
...<br />
}<br />
<br />
ClassB.h<br />
<br />
public __gc class A;<br />
<br />
public __gc class B<br />
{<br />
A a = new A();<br />
...<br />
}<br />
Many Thanks
theonewithtom
-- modified at 6:29 Tuesday 28th March, 2006
|
|
|
|
|
In class B use
#include "classA.h"
in class A use
#ifndef _CLASS_A_H_ // Win32 definition style instead #progma once
#define _CLASS_A_H_ // use this definition style if you want to include
public __gc class A {
...
};
#endif
ps: Don't forget to add ";" at the end of class
|
|
|
|
|
I'm not sure if you already figured this out, but you can use a forward declaration of a class like you can with functions/methods. Ex.
class myclass2; //forward declaration of a class.
class myclass1
{
myclass2 m_SecondClass;
....
};
class myclass2
{
myclass1 m_FirstClass
};
DWyvern
|
|
|
|
|
Whitch .NET framework are you using. If you use plain C++, then this thread supposted to be in Visual C++/MFC Forum.
I don't use Forward decleration. I sometimes declare a global class.
|
|
|
|
|
I have a c# app which references a managed c++ class dll which is wrapping an unmanaged win32 dll using the method described here[^]. I have set the c# app's properties to allow unmanaged code debugging (VS2005), but I am still unable to step into the win32 dll code. Everything is in the one visual studio solution. I have created a pre-build event for the c# app to copy the win32 dll to the c# apps debug folder (Id rather not have to do this, but it seems necessary).
Can someone please help me figure out why i cant debug the dll?
|
|
|
|
|
modify the project settings of the managed c++ project, change the output and debug target according to the C# app. start debugging from the managed c++ project.
My blogs:
http://blog.joycode.com/jiangsheng
http://blog.csdn.net/jiangsheng
http://bloglines.com/public/jiangsheng
Command what is yours
Conquer what is not
---Kane
|
|
|
|
|
Sorry, but I can't see any settings like that... what exactly are they called? Im using Visual Studio 2005.
|
|
|
|
|
Never mind, figured out my problem thanks. In the properties for the win32 project I had Linker>Debugging>Generate Debug Info turned off
|
|
|
|
|
Sir,
I want to connect vc++.net1.1 with sql server 2000.
In this I want to dynamically establish the connection and want to add the buttons named add , delete , edit , update , first, previous , last , next. In all these buttons I want to use the sql queries.
Can you please send me the code project links
I shall be very thankful to you.
Pankaj Garg
|
|
|
|
|
Sir,
I want to learn the deployment in vc++.net1.1.
Can you send me the tutorials.Or any link Please.
THANK YOU
Pankaj Garg
|
|
|
|
|
I have a problem when calling a function existing in the principle dialog from another dialog in the same project.this call creates an assertion failure exception when executing the following instruction:UpdateData(true) which is necessary to send a message via a socket in the principle dialog.
please help me.
lilas23
|
|
|
|
|
Hi
The problem is concerned with expanding and collapsing the treview node.
Like I expanded c: and c: shows windows , document and settings , program files.etc.Like
c:
My Documents
Windows
Program Files
Then next time I Unexpand the C: node.
Finally Again I Expand the C: node.
It shows the following structure.
C:
My Documents
Windows
Program Files
My Document
Windows
Program Files
I mean It show duplicacy of the three nodes two times .
If i delete the sub node on openeng the C:
Please tell me the way.
I am using action == 2 function.
even then it is showing the same problem
Thanks
|
|
|
|
|
hi,all
i am a new comer to this group
While programming i got an error which is some reference error or some thing else
Anyways i will give u my doe pls help me
#include <conio.h>
#include <string.h>
#include <iostream.h>
char* rmstr(char *whstr, char *strm)
{
char *ptr,*rem;
char temp[20];
clrscr();
int k=0;
do
{
ptr=strstr(whstr,strm);
if (ptr==NULL)
{
break;
}
for (int i=0;i
|
|
|
|
|
Would you mind posting it again? But this time please check "Ignore HTML tags in this message (good for code snippets)" because the code you've posted is currently incomplete.
for instance:
>> for (int i=0;i{
>> temp[k++]=whstr[i];
>> }
btw. The line below is probably causing your trouble.
strcpy(rem,whstr);
The rem pointer has not been initialized before or to be more precise you haven't allocated any memory, even though you're applying strcpy on it.
cheers Tobias
|
|
|
|
|
oh........
thanks for this valuable help
its get ok when i initialised it as u suggest
thanks thanks thanks a lot
shamnar
|
|
|
|
|
sir
this time i met with another problem.
that is
if my input to the fn is "thisa" "is" then i am getting o/p "thisa" instead of "tha"
please help me.
now i am sending the code along with this mail
#include <conio.h>
#include <stdio.h>
#include <string.h>
char* rmstr(char *whstr, char *strm)
{
char *ptr,*rem="";
char temp[10];
clrscr();
int k=0;
do
{
ptr=strstr(whstr,strm);
if (ptr==NULL)
{
break;
}
for (int i=0;i<ptr-whstr;i++)
{
temp[k++]=whstr[i];
}
ptr=ptr+strlen(strm);
strcpy(rem,whstr);
rem=rem+strlen(strm);
strcpy(whstr,ptr);
}while(1);
temp[k]='\0';
strcat(temp,rem);
return(temp);
}
void main()
{
char *temp;
stcpy(temp,rmstr("thisa","is"));
cout<<temp;
}
shamnar
|
|
|
|
|
Hi,
as I said before, look at your memory allocation.
// this won't work unless you initialize *temp
char *temp;
stcpy(temp,rmstr("thisa","is"));
// for instance
char *temp = new char(256);
strcpy(temp,rmstr("thisa","is"));
Oh, and by the way this won't work either:
char *ptr,*rem=""
you have initialized that rem pointer, but with a reference to an empty string. As long as there is no memory assigned to it strcpy(rem,whstr); will fail. In addition I would really recommend you to have a look into a C/C++ tutorial, because this knowledge is essential.
regards Tobias
-- modified at 2:06 Monday 27th March, 2006
|
|
|
|
|
could you send me a function which accepts two strings as i/p and returns another string which doesnt contain the second string in first string
for eg if i call like this
rmstr("this","is")
it should return "th"
sir please dont use std::string because my compiler is not supporting it
anyways thanks for ur valuable help, let me acknowledge for ur kindness to spend time for this.
shamnar
|
|
|
|
|
Shamnar,
let me guess, that is your homework??? I mean it is a little obvious if you say that you cant use std::string due to your compiler. Well it might be or not, however those pointer stuff is essential. I do understand that it is quite weird stuff but it won't get you far if don't how to deal with it.
However, i've just programmed that function. But to make it not too easy i have removed some parts from it.
char* rmstr(char* searchstring, char* morphem)
{
char* tmp;
char* resultstring = new char(strlen(searchstring));
*resultstring = '\0';
while( ( tmp = strstr(searchstring, morphem)) )
{
int len ...;
char* result = new ...;
strncpy(...);
searchstring = (...);
*(result+len) = '\0';
strcat(...);
}
return resultstring;
}
Tobias
|
|
|
|
|
finaly i did it.
thanks for ur advices and clues u have given to me.
but i made one more instruction. i am sending it along with this
char* rmstr(char* searchstring, char* morphem)
{
char* tmp;
char* resultstring = (char *) malloc(strlen(searchstring));
*resultstring = '\0';
while( ( tmp = strstr(searchstring, morphem))!='\0')// )
{
int len=strlen(searchstring)-strlen(tmp); //...;
char* result = (char *) malloc(len);//...;
strncpy(result,searchstring,len);//...);
searchstring = tmp+strlen(morphem);//(...);
*(result+len) = '\0';
strcat(resultstring,result);//...);
free (result);
}
if (searchstring!='\0')
strcat(resultstring,searchstring);
free (resultstring);
return resultstring;
}
thanks for make me to study pointers.
shamnar
|
|
|
|
|
Is there any way in a nested class to access non-static members from the current instance of the enclosing class? ex.
class outer<br />
{<br />
public:<br />
int m_value;<br />
int m_value2<br />
<br />
class inner<br />
{<br />
int getAccess()<br />
{<br />
return (??)m_value;<br />
}<br />
}<br />
}<br /> Thanks
Doug
|
|
|
|
|
Make that...
__gc class outer<br />
{<br />
public:<br />
int m_value;<br />
int m_value2<br />
<br />
__gc class inner<br />
{<br />
int getAccess()<br />
{<br />
return (??)m_value;<br />
}<br />
}<br />
}<br /> ...forgot the managed qualifiers...
|
|
|
|
|
Hi Douglas,
I don't know exactly if this helps but I'll give it a try. Basically i have just converted the C# example of nested classes into C++/CLI. It seems to me that this is a way to get it working (it actually did work):
public ref class Container
{
public:
Container(void);
private:
int m_value;
public:
void SetValue(int pVal)
{
m_value = pVal;
}
public:
ref class InnerClass
{
private:
Container^ m_parent;
public:
InnerClass(void) {};
InnerClass(Container^ parent)
{
m_parent = parent;
}
public:
int getAccess()
{
return m_parent->m_value;
}
};
};
Container^ outer = gcnew Container();
Container::InnerClass^ nested = gcnew Container::InnerClass(outer);
Console::WriteLine(nested->getAccess()); // prints 4
outer->SetValue(5);
Console::WriteLine(nested->getAccess()); // prints 5
hope this helps,
best regards Tobias
|
|
|
|
|
Yeah, that's what I ended up doing. I wonder if there's a cleaner way, though...
|
|
|
|
|