property structure/object

J

john townsley

hi

I am using VC6

1)in C++ can you have a property of a class of type structure

struct MyStruct{
public:
int t ;
};

class Oven {
public:
MyStruct Mstruct;
}

I keep getting errors, I dont know how to declare a property of type struct

2) Can you declare a property to be of type another Class (no inheriting)
and you could refere to these properties like
Obj1.Obj2.prop1 = ....


thanks
 
T

ToeNi

class Oven {
public:
MyStruct Mstruct;
}

Bro,
Your just missing ";" character in class defining
 
M

Mike Wahler

john townsley said:
hi

I am using VC6

1)in C++ can you have a property of a class of type structure

struct MyStruct{
public:
int t ;
};

class Oven {
public:
MyStruct Mstruct;
}
};


I keep getting errors,

And they are?
I dont know how to declare a property of type struct

2) Can you declare a property

The C++ term is 'data member'.
to be of type another Class (no inheriting)
and you could refere to these properties like
Obj1.Obj2.prop1 = ....

Yes.

Once you fix the minor typo I pointed out, the above
should compile just fine. If you post the *exact*
code you're trying, along with the compiler errors,
perhaps we can help.

-Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,197
Messages
2,571,038
Members
47,633
Latest member
BriannaLyk

Latest Threads

Top