property structure/object

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • john townsley

    property structure/object

    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


  • ToeNi

    #2
    Re: property structure/object

    class Oven {
    public:
    MyStruct Mstruct;
    }

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

    Comment

    • ToeNi

      #3
      Re: property structure/object

      this is usefull link as well.


      Comment

      • Mike Wahler

        #4
        Re: property structure/object


        "john townsley" <johntownsley@o ptusnet.com.au> wrote in message
        news:41dcb325$0 $4151$afc38c87@ news.optusnet.c om.au...[color=blue]
        > 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;
        > }[/color]

        };
        [color=blue]
        >
        > I keep getting errors,[/color]

        And they are?
        [color=blue]
        >I dont know how to declare a property of type struct
        >
        > 2) Can you declare a property[/color]

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

        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


        Comment

        Working...