-
March 28th, 2006, 01:37 PM
#1
Class member problem...help
Here is a snipit of my code:
Class header {
public:
double timeTag;
short size;
};
Class message {
public:
short goStatus;
header msgHeader;
};
The two classes above are in a single file.
in a different file i have:
message myMessage;
myMessage.msgHeader.timeTag = ....;
the error im getting is
: error C2039: 'msgHeader' : is not a member of 'message'
myMessage.goStatus = ... "works"
-
March 28th, 2006, 02:00 PM
#2
Re: Class member problem...help
Probably a typo... This can't be your actual code ('Class' is not a C++ keyword).
Please post your actual code, and please use code tags when doing so.
-
March 28th, 2006, 02:31 PM
#3
Re: Class member problem...help
I can't post my actual code it's classified but, here is a model.....
in file Dummy.h
Code:
#include "DummyDefs_h"
#ifndef Dummy_h
#define Dummy_h
class Dummy1 {
public:
double var1;
short var2;
short var3;
short var4;
DummyEnum var5;
};
class Dummy2 {
public:
Dummy1 myDummy;
short var6;
short var7;
double var8;
struct {
unsigned int var9;
} dummyStruct;
};
#endif
in dummyProcessing.cpp file:
Code:
#include "dummyProcessing.h"
#include "dummy.h"
(I'm going to omit the constructor and deconstructor code as well as the
funtion code.)
Dummy2 myMsg;
myMsg.myDummy.var1 = 9.0; // does not work
myMsg.myDummy.var2 = 3; // does not work
....
....
myMsg.var6 = 7; // that works...
myMsg.var7 = 7; // that works...
myMsg.var8 = 7.0; // that works...
error message is 'myDummy' is not a member of 'Dummy2
i have checked for typo's i really don't think it's that....
thxs for the help
Last edited by cilu; March 28th, 2006 at 03:37 PM.
Reason: code tags added
-
March 28th, 2006, 02:59 PM
#4
Re: Class member problem...help
Originally Posted by tsnofvdr
error message is 'myDummy' is not a member of 'Dummy2
i have checked for typo's i really don't think it's that....
Check again?
Here is the code that works (looks just like yours):
Code:
class B
{
public:
short var2;
};
class A
{
public:
B b;
short var6;
};
int main()
{
A a;
a.b.var2 = 42;
return 0;
}
Nobody wants to see your secret code, but if you could provide a sample that demonstrates your problem - it'll be much easier to figure what's wrong.
Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
Convenience and productivity tools for Microsoft Visual Studio:
FeinWindows - replacement windows manager for Visual Studio, and more...
-
March 28th, 2006, 03:02 PM
#5
Re: Class member problem...help
Originally Posted by tsnofvdr
I can't post my actual code it's classified but, here is a model.....
1) Please use code tags. Your code is unreadable without them.
2) If you're going to make a "model", make one that duplicates your error with the smallest amount of compilable code where we don't have to fill in anything, move anything around, try to figure out what you meant, etc. All that is necessary for us to do is to copy and paste the example directly into the compiler and compile it, and then see the error for ourselves.
Regards,
Paul McKenzie
-
March 28th, 2006, 03:40 PM
#6
Re: Class member problem...help
I can't post my actual code it's classified but, here is a model.....
Your model is definitelly ok.
I suggest to check the commas after all classes, structs and enums. Missing a comma can lead to strange error messages.
Code:
class foo
{
}; // <-- make sure ; is placed here
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|