locked
error C3699: '*' : cannot use this indirection on type '

    Question

  • Hi All,

    Here is what I am trying to do and I hope someone will have better explanation what is going on.

    I have created two classes classA and classB. In classB I would like to create a method that returns a vector of classA objects. Here is what I did

    myclassa.h

    namespace myClassA{
       public ref classA{
       };
    }

    ...
    myclassb.cpp
    namespace myClassB{
     
        std::vector<myClassA::classA> get_classAObjects(){
           std::vector<myClassA::classA> vtemp;
           loop (...){
           myClassA::classA atemp;
          vtemp.push_back(atemp);
         return vtemp;
       }
    }
    myclassb.h
    namespace myClassB{
       public ref classB{
          std::vector<myClassA::classA> get_classAObjects();
       };
    }


    This works fine in c++ but when I tried to use VS2005 I get an error similar to this error C3699: '*' : cannot use this indirection on type ' <myClassA::classA>'.
    Basically at every line I used myClassA::classA.

    Can someone tell me why do I get this error and how to resolve it?  I appreciate any kind of suggestions.

    Jaz.

    Monday, July 09, 2007 3:26 PM

Answers

  • Your code is an odd mix of managed and unmanaged code.  You'll need to use the "hat" to create a reference to managed class classA:
      myClassA:: classA^ atemp.
    and
      std:: vector<myClassA:: classA^>

    And you'll need to use the gcnew operator to create an instance of classA.  You're not going to get far with this, I'd recommend a book about programming in the C++/CLI syntax.
    Tuesday, July 10, 2007 4:05 AM
    Moderator
  • The .NET framework has excellent collection classes that are on par with what the STL can provide.  You'll usually end up having to throw the switch all the way, getting a little pregnant rarely works.  There was an attempt at making a managed version of the STL but it hasn't seen the light of day yet, although it has been promised for over 5 years now.  When somebody gets stuck like this, I usually recommend taking a serious look at C#.  Sorry, I'm sure that's not what you wanted to hear....
    Tuesday, July 10, 2007 9:45 PM
    Moderator

All replies

  • Your code is an odd mix of managed and unmanaged code.  You'll need to use the "hat" to create a reference to managed class classA:
      myClassA:: classA^ atemp.
    and
      std:: vector<myClassA:: classA^>

    And you'll need to use the gcnew operator to create an instance of classA.  You're not going to get far with this, I'd recommend a book about programming in the C++/CLI syntax.
    Tuesday, July 10, 2007 4:05 AM
    Moderator
  • I totally agree with you.  I just started working on this a week ago.  So I have so much to learn I guess.  However, I made some progress.

    Instead of creating that method to return a vector of objects classA, what I did is created a memeber in classB that is a vector which holds the classA type objects.  That works fine in c++ but in C++/CLI I get this error

    error C4368: cannot define 'students' as a member of managed 'myClassA::classA': mixed types are not ...

    namespace myClassB{
    public ref classB{
      public:
         static std::vector< myClassA::classA ^ > students;
    }

    In fact I am not sure where to place it in my classb.cpp or classb.h file. Any tips?
    Thanks
    Tuesday, July 10, 2007 8:14 PM
  • The .NET framework has excellent collection classes that are on par with what the STL can provide.  You'll usually end up having to throw the switch all the way, getting a little pregnant rarely works.  There was an attempt at making a managed version of the STL but it hasn't seen the light of day yet, although it has been promised for over 5 years now.  When somebody gets stuck like this, I usually recommend taking a serious look at C#.  Sorry, I'm sure that's not what you wanted to hear....
    Tuesday, July 10, 2007 9:45 PM
    Moderator