constructors help

Alright, i'm working on a new application, in wich i need my own TreeNode Variants, with his own information. I made a new struct called InfoStruct in wich i hold my own Information. Next, i create this new class, VCNode wich is a inferred class from TreeNode.

public value class InfoStruct

{

//TODO: Put all the nessesary info here.

String^ Name;

};

public ref class VCNode : public TreeNode

{

public:

VCNode( String^ name, InfoStruct^ _InfoStruct, int _imageIndex, int _selectedImageIndex) : TreeNode( name, _imageIndex, _selectedImageIndex ); //Constructor

private:

InfoStruct^ Info;

};


with this pease of code, i got alot of errors, and i was hoping, you guys could tell me what i do wrong.
Thanks already!



Answer this question

constructors help

  • Tony Zhang

    You did remember #include the header file in *.cpp file There errors you are getting indicate to me that the compiler has no clue about the types you are using in the constructor - and this usually means a missing header file.

  • Prabs

    You haven't provided enough information for us to help.  What are the first few errors you are getting


  • Kurt De Kempeneer

    Alright, a little update. If i put the code straight under the declaration, it works, ( putting the code in the header file )
  • MeDaN00b

    oh haha, never knew i would still fall for that stupidness :D thanks thats exactly the thing :)
    didnt saw it, because of i was already using lots of other functions in the same file

  • Remulac

    Engine::VCNode::VCNode( String^ name, InfoStruct^ _InfoStruct, int _imageIndex, int _selectedImageIndex) : TreeNode( name, _imageIndex, _selectedImageIndex )

    {

    Info = _InfoStruct;

    }

    thats the constructor code, just  a very small piece of it, but even with this code i get the same errors:

    Error 2 error C2059: syntax error : '}' c:\documents and settings\koen\mijn documenten\visual studio 2005\projects\testapp_04\engine\Engine_Tree.h 60
    Error 9 error C2065: 'FileName' : undeclared identifier c:\Documents and Settings\Koen\Mijn documenten\Visual Studio 2005\Projects\TestApp_04\Engine\Engine_Tree.cpp 20
    Error 12 error C2065: 'obj' : undeclared identifier c:\Documents and Settings\Koen\Mijn documenten\Visual Studio 2005\Projects\TestApp_04\Engine\Engine_Tree.cpp 28
    Error 5 error C2065: 'Tree' : undeclared identifier c:\Documents and Settings\Koen\Mijn documenten\Visual Studio 2005\Projects\TestApp_04\Engine\Engine_Tree.cpp 10
    Error 14 error C2227: left of '->Add' must point to class/struct/union/generic type c:\Documents and Settings\Koen\Mijn documenten\Visual Studio 2005\Projects\TestApp_04\Engine\Engine_Tree.cpp 39
    Error 8 error C2227: left of '->Clear' must point to class/struct/union/generic type c:\Documents and Settings\Koen\Mijn documenten\Visual Studio 2005\Projects\TestApp_04\Engine\Engine_Tree.cpp 13
    Error 7 error C2227: left of '->Nodes' must point to class/struct/union/generic type c:\Documents and Settings\Koen\Mijn documenten\Visual Studio 2005\Projects\TestApp_04\Engine\Engine_Tree.cpp 13
    Error 13 error C2227: left of '->Nodes' must point to class/struct/union/generic type c:\Documents and Settings\Koen\Mijn documenten\Visual Studio 2005\Projects\TestApp_04\Engine\Engine_Tree.cpp 39
    Error 17 error C2227: left of '->Nodes' must point to class/struct/union/generic type c:\Documents and Settings\Koen\Mijn documenten\Visual Studio 2005\Projects\TestApp_04\Engine\Engine_Tree.cpp 51
    Error 10 error C2275: 'System::String' : illegal use of this type as an expression c:\Documents and Settings\Koen\Mijn documenten\Visual Studio 2005\Projects\TestApp_04\Engine\Engine_Tree.cpp 20
    Error 15 error C2275: 'System::String' : illegal use of this type as an expression c:\Documents and Settings\Koen\Mijn documenten\Visual Studio 2005\Projects\TestApp_04\Engine\Engine_Tree.cpp 48
    Error 11 error C2448: 'Engine::_TreeEngine::LoadTreeContent' : function-style initializer appears to be a function definition c:\Documents and Settings\Koen\Mijn documenten\Visual Studio 2005\Projects\TestApp_04\Engine\Engine_Tree.cpp 21
    Error 6 error C2448: 'Engine::_TreeEngine::ResetTree' : function-style initializer appears to be a function definition c:\Documents and Settings\Koen\Mijn documenten\Visual Studio 2005\Projects\TestApp_04\Engine\Engine_Tree.cpp 11
    Error 16 error C2448: 'Engine::_TreeEngine::SaveTreeContent' : function-style initializer appears to be a function definition c:\Documents and Settings\Koen\Mijn documenten\Visual Studio 2005\Projects\TestApp_04\Engine\Engine_Tree.cpp 49
    Error 4 error C2612: trailing 'using' illegal in base/member initializer list c:\Documents and Settings\Koen\Mijn documenten\Visual Studio 2005\Projects\TestApp_04\Engine\Engine_Tree.cpp 6
    Error 3 error C2630: ';' found in what should be a comma-separated list c:\Documents and Settings\Koen\Mijn documenten\Visual Studio 2005\Projects\TestApp_04\Engine\Engine_Tree.cpp 6


    if a leave the part of TreeNode Constructer away, the program builds fine


  • constructors help