Skocz do zawartości

Witamy w Nieoficjalnym polskim support'cie AMX Mod X

Witamy w Nieoficjalnym polskim support'cie AMX Mod X, jak w większości społeczności internetowych musisz się zarejestrować aby móc odpowiadać lub zakładać nowe tematy, ale nie bój się to jest prosty proces w którym wymagamy minimalnych informacji.
  • Rozpoczynaj nowe tematy i odpowiedaj na inne
  • Zapisz się do tematów i for, aby otrzymywać automatyczne uaktualnienia
  • Dodawaj wydarzenia do kalendarza społecznościowego
  • Stwórz swój własny profil i zdobywaj nowych znajomych
  • Zdobywaj nowe doświadczenia

Dołączona grafika Dołączona grafika

Guest Message by DevFuse
 

Zdjęcie
C++

Błąd w Visual C++

c++

  • Nie możesz napisać tematu
  • Zaloguj się, aby dodać odpowiedź
2 odpowiedzi w tym temacie

#1 b0xer

    Zaawansowany

  • Użytkownik

Reputacja: 9
Nowy

  • Postów:77
  • Imię:Artur
  • Lokalizacja:gdansk
Offline

Napisano 08.10.2012 16:20

Otworzyłem program i go najpierw zapisałem pod nazwą "losowanie" po czym napisałem program lecz po napisaniu wyskoczyły mi 3 błędy:
Dołączona grafika
z tym że ten drugi błąd to jest z kramelką koło tego pierwszego.

Bardzo proszę napisać co mam źle.
Są to moje początki więc proszę się nie śmiać





#pragma once


using namespace Losowanie;
{

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
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}

protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Button^  button1;
protected:
private: System::Windows::Forms::TextBox^  textBox1;
private: System::Windows::Forms::TextBox^  textBox2;
private: System::Windows::Forms::TextBox^  textBox3;
private: System::Windows::Forms::Button^  button2;
private: System::Windows::Forms::Label^  label1;

private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->button1 = (gcnew System::Windows::Forms::Button());
this->textBox1 = (gcnew System::Windows::Forms::TextBox());
this->textBox2 = (gcnew System::Windows::Forms::TextBox());
this->textBox3 = (gcnew System::Windows::Forms::TextBox());
this->button2 = (gcnew System::Windows::Forms::Button());
this->label1 = (gcnew System::Windows::Forms::Label());
this->SuspendLayout();
//
// button1
//
this->button1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(238)));
this->button1->Location = System::Drawing::Point(337, 48);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(107, 36);
this->button1->TabIndex = 0;
this->button1->Text = L"Losowanie";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
//
// textBox1
//
this->textBox1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 72, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(238)));
this->textBox1->Location = System::Drawing::Point(13, 48);
this->textBox1->Multiline = true;
this->textBox1->Name = L"textBox1";
this->textBox1->Size = System::Drawing::Size(81, 115);
this->textBox1->TabIndex = 1;
//
// textBox2
//
this->textBox2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 72, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(238)));
this->textBox2->Location = System::Drawing::Point(127, 48);
this->textBox2->Multiline = true;
this->textBox2->Name = L"textBox2";
this->textBox2->Size = System::Drawing::Size(86, 115);
this->textBox2->TabIndex = 2;
//
// textBox3
//
this->textBox3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 72, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(238)));
this->textBox3->Location = System::Drawing::Point(236, 48);
this->textBox3->Multiline = true;
this->textBox3->Name = L"textBox3";
this->textBox3->Size = System::Drawing::Size(83, 115);
this->textBox3->TabIndex = 3;
//
// button2
//
this->button2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(238)));
this->button2->Location = System::Drawing::Point(314, 249);
this->button2->Name = L"button2";
this->button2->Size = System::Drawing::Size(107, 42);
this->button2->TabIndex = 4;
this->button2->Text = L"Koniec";
this->button2->UseVisualStyleBackColor = true;
this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click);
//
// label1
//
this->label1->AutoSize = true;
this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(238)));
this->label1->Location = System::Drawing::Point(35, 209);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(191, 20);
this->label1->TabIndex = 5;
this->label1->Text = L"Spróbuj jeszcze raz \?\?";
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(470, 320);
this->Controls->Add(this->label1);
this->Controls->Add(this->button2);
this->Controls->Add(this->textBox3);
this->Controls->Add(this->textBox2);
this->Controls->Add(this->textBox1);
this->Controls->Add(this->button1);
this->Name = L"Form1";
this->Text = L"Form1";
this->ResumeLayout(false);
this->PerformLayout();

}
#pragma endregion
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e)
{
int a,b,c;
Random.Next(0,10);
textBox1->Text=a.ToString();
textBox2->Text=b.ToString();
textBox3->Text=c.ToString();
if(a==b && b==c)
label1->Text="Wygrałeś";
if(a!=b && b!=c)
label1->Text="Spróbuj jeszcze raz";
};
private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e)
{
Close();
}
}




Dokładnie tu występują dwa błędy:


using namespace Losowanie;
{

using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;

a ten 3 błąd też się odnosi do tych dwóch:

// Losowanie.cpp : main project file.

#include "stdafx.h"
#include "Form1.h"

using namespace Losowanie;

[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
// Enabling Windows XP visual effects before any controls are created
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false); 

// Create the main window and run it
Application::Run(gcnew Form1());
return 0;
}

Użytkownik b0xer edytował ten post 08.10.2012 16:32

  • +
  • -
  • 0

#2 Play4Fun

    Zaawansowany

  • Użytkownik

Reputacja: 15
Początkujący

  • Postów:86
  • GG:
  • Imię:Dawid
  • Lokalizacja:Lublin
Offline

Napisano 17.10.2013 19:40

Jeżeli dołączasz pliki zewnętrzne definiujesz biblioteki to w przykładzie:

#include "stdafx.h"
#include "Form1.h"

zamiast 

".."

 powinno być 

<..>

Jeżeli chodzi o:

using namespace Losowanie;
{

using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;

To pierwszy raz spotykam się z czymś takim, jeżeli już to:

using namespace Losowanie;
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;

bez zbędnego 

{

Poza tym napisz dokładne logi errory, ponieważ nie mogę ich rozszyfrować na tym zdjęciu ;)

 

Użytkownik Play4Fun edytował ten post 17.10.2013 19:40

  • +
  • -
  • 0

#3 DarkGL

    Nie oddam ciasteczka !

  • Administrator

Reputacja: 6 555
Godlike

  • Postów:11 980
  • GG:
  • Steam:steam
  • Imię:Rafał
  • Lokalizacja:Warszawa
Offline

Napisano 18.10.2013 15:20

Jeżeli dołączasz pliki zewnętrzne definiujesz biblioteki to w przykładzie:
#include "stdafx.h"
#include "Form1.h"zamiast ".." powinno być 
<..>

nie prawda , obie formy są poprawne mają troche inne działanie ale są poprawne


Użytkownik DarkGL edytował ten post 18.10.2013 15:21

  • +
  • -
  • 1





Również z jednym lub większą ilością słów kluczowych: c++

Użytkownicy przeglądający ten temat: 0

0 użytkowników, 0 gości, 0 anonimowych