none
Fehlermedlung: error C4430: missing type specifier - int assumed. Note: C++ does not support default-int RRS feed

  • Frage

  • #pragma once
    
    
    
    #include "stdafx.h"
    
    #include "multiline.h"
    
    
    
    namespace optik {
    
    
    
    	using namespace System;
    
    	using namespace System::ComponentModel;
    
    	using namespace System::Collections;
    
    	using namespace System::Windows::Forms;
    
    	using namespace System::Data;
    
    	using namespace System::Drawing;
    
    
    
    	/// <summary>
    
    	/// Summary for Form1
    
    	///
    
    	/// WARNING: If you change the name of this class, you will need to change the
    
    	///          'Resource File Name' property for the managed resource compiler tool
    
    	///          associated with all .resx files this class depends on.  Otherwise,
    
    	///          the designers will not be able to interact properly with localized
    
    	///          resources associated with this form.
    
    	/// </summary>
    
    	public ref class Form1 : public System::Windows::Forms::Form
    
    	{
    
    		int i;
    
    		static array<multiline ^> ^beams = gcnew array<multiline ^>(18);
    
    		static multiline ^beam0 = gcnew multiline(0, 0, 0, 0, 0);
    
    		static multiline ^beam1 = gcnew multiline(1, 1, 1, 1, 1);
    
    		static beams[0] = beam0;
    
    
    
    	public:
    
    		Form1(void)
    
    		{
    
    			InitializeComponent();
    
    			//
    
    			//TODO: Add the constructor code here
    
    			//
    
    		}
    
    
    
    ...
    
    
    Hallo,
    in meinem Projekt möchte ich ein array (beams) benutzen in dem Verweise auf Instanzen einer Klasse (multiline) gespeichert werden.
    In Zeile 30 möchte ich mit "static beams[0] = beam0" dem nullten Element des Arrays den Verweis zur Instanz "beam0" zuweisen.
    Beim build bekomme ich die Fehlermeldungen:

    Form1.h(30) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
    Form1.h(30) : error C2372: 'optik::Form1::beams' : redefinition; different types of indirection

    Kann mir jemand erklären wo der Fehler liegt?
    Danke
    Bernhard

    Sonntag, 28. Februar 2010 18:29

Antworten

  • Hallo bobydylan
    versuch mal hiermit:
    public ref class Form1 : public System::Windows::Forms::Form
    	{
    		int i;
    		static array<multiline ^> ^beams;
    		static multiline ^beam0;
    		static multiline ^beam1;
    
    	public:
    		Form1(void)
    		{
    			InitializeComponent();
    			//
    			//TODO: Add the constructor code here
    			//
    			beams = gcnew array<multiline ^>(18);
    			beam0 = gcnew multiline(0, 0, 0, 0, 0);
    			beam1 = gcnew multiline(1, 1, 1, 1, 1);
    			beams[0] = beam0;
    		}

    Markus F.
    Sonntag, 28. Februar 2010 18:45

Alle Antworten

  • Hallo bobydylan
    versuch mal hiermit:
    public ref class Form1 : public System::Windows::Forms::Form
    	{
    		int i;
    		static array<multiline ^> ^beams;
    		static multiline ^beam0;
    		static multiline ^beam1;
    
    	public:
    		Form1(void)
    		{
    			InitializeComponent();
    			//
    			//TODO: Add the constructor code here
    			//
    			beams = gcnew array<multiline ^>(18);
    			beam0 = gcnew multiline(0, 0, 0, 0, 0);
    			beam1 = gcnew multiline(1, 1, 1, 1, 1);
    			beams[0] = beam0;
    		}

    Markus F.
    Sonntag, 28. Februar 2010 18:45
  • Hallo Markus,

    vielen Dank. Hat funktioniert (nachdem ich den ganzen Nachmittag rumprobiert habe ;-)

    Bernhard

    Sonntag, 28. Februar 2010 18:52
  • man kann in
    public
     ref class
     Form1 : public
     System::Windows::Forms::Form
    
    nicht initialisieren, nur deklarieren ;)

    Markus F.
    Sonntag, 28. Februar 2010 18:56