|
to compile and run that code:
struct BB;
typedef struct _AA {
struct BB* bb;
int a;
} AA, *PAA;
typedef struct _BB {
struct AA* aa;
int b;
} BB, *PBB;
main()
{
AA a;
BB b;
a.bb = &b;
b.aa = &a;
a.bb->b = 1;
b.aa->a = 3;
}
chesnokov
|
|
|
|
|
This works fine for me:
#include "stdafx.h"
struct BB;
struct AA
{
struct BB* bb;
int a;
};
struct BB
{
struct AA* aa;
int b;
};
void main()
{
struct AA a;
struct BB b;
a.bb = &b;
b.aa = &a;
a.bb->b = 1;
b.aa->a = 3;
}
Steve
|
|
|
|
|
You're having trouble with them being declared as pointers, and want them as real contained structs.
To borrow a phrase, "Imagine if you could do what you're asking".
AA would contain a BB which would contain an AA which would contain a BB which would contain an AA which would contain a BB which would contain an AA which would contain a BB which would contain an AA which would contain a BB which would contain an AA which would contain a BB which would contain an AA which would contain a BB which would contain an AA which would contain a BB...
I hope I'm getting the point across - I'm bored of typing. But your structure would end up infinitely large.
You can contain a *pointer* to your structures evil twin - a pointer only takes up a few bytes. But you need to give the pointer something to point to.
So:
struct BB;
struct AA
{
struct BB *bb;
int a;
};
struct BB
{
struct AA *aa;
int b;
};
main ()
{
AA a;
BB b;
a.bb->b = 1;
}
In the above example, C isn't psychic, so hasn't pointed A.bb at any BB structure. How can it? That's your job.
Try the below code.
AA a;
BB b;
a.bb = &b;
b.aa = &a;
a.bb->b = 1;
b.aa->a = 3;
Now your two structure can talk to each other to their heart's content.
I'd go back to your C book, and look up linked lists - it'll give you a light bulb moment about pointers.
Iain.
Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.
|
|
|
|
|
Iain Clarke wrote: I'd go back to your C book
If any.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Do not push to other limits I know to self refere them in future the glitch is it does not compile??
Try it yourself:
AA a;
BB b;
a.bb = &b;
b.aa = &a;
a.bb->b = 1; //error C2037
b.aa->a = 3; //error C2037
chesnokov
|
|
|
|
|
My apologies, I hadn't fully switched off my C++ brain.
try:
struct AA a;
struct BB b;
a.bb = &b;
b.aa = &a;
a.bb->b = 1;
b.aa->a = 3;
Though you could have worked that out for yourself...
Iain.
Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.
|
|
|
|
|
Iain Clarke wrote: Though you could have worked that out for yourself...
Another hint the C book was lost sometime.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Good day Guys,
Just would like to ask for help on this, how do I disable a tab in CTabCtrl?
I have a custom class extending CTabCtrl for some processing and also 3 Dialogs as Tabs.
On runtime, while processing on one tab, I would like to disable the other 3 tabs as not to mess
with the processing.
Thanks in advance
rbmarasigan2001
|
|
|
|
|
My first thought was "what a lazy question! Just called CTabCtrl::EnableItem (n, FALSE), or SetStyle (some struct with enable flag turned off)"...
But neither CTabCtrl, or (more authoratively) appear to have any disable tab functionality.
In my software, I don't use CTabCtrl as such - I use CFolderTabCtrl written by Paul diLascia in October 2002's MSDN magazine. Lot's of nice goodies in it, which hopefully will help you. You may even find it has the functionality you've added yourself...
http://msdn.microsoft.com/en-us/magazine/cc188936.aspx[^]
Iain.
Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.
|
|
|
|
|
Hi every one!
I have started a project using ciphering. That is going to be my last project in my school!
My teacher has told me this project is going to be published with no fee in the internet.
I want to use RSA and SHA1 taken by XYSSL Cristophe's Devine project (you may know : www.xyssl.org)
and make some modifications. How can do it so as to make it by low?
Also: What does it mean XYSSL having GPL license?
thanks!
|
|
|
|
|
See here[^] Im not sure its helpful for you or no?
|
|
|
|
|
|
Dennis L wrote: My teacher has told me this project is going to be published with no fee in the internet.
Not really a programming answer, but this seems a bit wrong to me. Surely this is work that you will create - it's valid for your teacher to mark it, and maybe keep confidential copies for reference in case someone challenges her marks - but why does she have a right to give your work to the world?
If *you* allowed it to be published to the world, then great. I've written some articles here, and am happy to give back to the greater community. But I'd be peeved if I had no choice about it.
Would you fail if you handed in the code with "Copyright Dennis L, not GPL, not using GPL, and not to be published without permission" on the top of every page?
Saying that, if you use GPL components, their license will infect your code too, I suppose.
Iain.
Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.
|
|
|
|
|
I have problems compiling my project.
There a two header-files:
the first one, ClassA.h:
#include "ClassB.h"
class ClassA
{
...
private:
ClassB classB;
...
}
and the second, ClassB.h:
#include "ClassA.h"
class ClassB
{
...
private:
ClassA classA;
...
}
So ClassA requires ClassB and ClassB requires ClassA.
The Compiler doesnt semm to like this kind of cross-requirements.
How can i solve this problem?
|
|
|
|
|
The way you're going about things doesn't make sense if you think about it. If Class A contains an instance of Class B and Class B contains an instance of Class A you've got something akin to infinite recursion. Perhaps this diagram will clarify this:
Class A
{
Class B
{
Class A
{
Class B
{
Class A
{
.
.
.
}
}
}
}
}
Steve
|
|
|
|
|
Why vote down this you clowns? This post explains why the approach doesn't make sense and the next suggests a solution.
Steve
|
|
|
|
|
"Vote me down, and I shall become more popular than you can imagine!"
Maybe the thought of an infinite struct blew their minds?
Iain.
Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.
|
|
|
|
|
Perhaps something like this is what you're after:
In "ClassA.h":
class B;
class A
{
...
private:
ClassB &classB;
};
In "ClassB.h":
class A;
class B
{
...
private:
ClassA &classA;
};
Steve
|
|
|
|
|
Ah this seems to work!
But im a little confused now.
Isnt it kind of standard to communicate between classes like this:
ClassA.h:
...
#include "ClassA.h"
...
ClassA.cpp:
...
ClassB* pObjB;
pObjB=new ClassA(this);
...
ClassB.h:
...
class ClassA; (<-Problem solving forward reference, instead of include)
class ClassB
{
private:
ClassA* pObjA;
}
...
ClassB.cpp:
...
ClassB::ClassB(ClassA* pObjA)
{
this->pObjA=pObjA;
}
...
pObjA->gimmeSomeClassAMember();
...
|
|
|
|
|
I feel extremely bad for having to ask this, but how do i publish my program in C++ to an executable install to send to my other computer.
|
|
|
|
|
Do you need to an installer?
|
|
|
|
|
well maybe not an installer, but when i put the release file on my other comp it wouldn't work, couldn't find mscores.dll or something to that extent.
|
|
|
|
|
It's called "deployment", and you shouldn't feel bad asking about it.
It can be a fairly complex topic.
Deployment (C++)[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks, alright. I'll start reading and thanks for the reply.
|
|
|
|
|
Sorry to bring this up again, but i cannot figure this out.
It says here:
"The most comprehensive way to determine which DLLs your application depends on is to open the application using the Dependency Walker (depends.exe), which ships with Visual C++. Depends.exe is installed to \Microsoft Visual Studio 2005\Common7\Tools\bin. Note that depends.exe is only installed if you select the Win32 Platform SDK Tool, which is in the Visual C++ Tools category of the Visual C++ custom installation."
But i have Microsoft Visual Studio 9.0\Common7\Tools\ but no bin. I figured out that my program depends on MFC, but i cannot figure out how to continue to publish my program to send to my other computer without having to install Visual Studio's on it.
Is their an article that could help me out with this, i cannot understand the MSDN article explaining it, and the things they point out just don't seem to fit. I'm missing a few items that they have pointed out.
|
|
|
|