Anonymní profil VereWolf – Programujte.com
 x   TIP: Přetáhni ikonu na hlavní panel pro připnutí webu

Anonymní profil VereWolf – Programujte.comAnonymní profil VereWolf – Programujte.com

 

Příspěvky odeslané z IP adresy 88.100.108.–

Právo a podnikání › Jak označit svoji práci
3. 11. 2012   #165825

Ahoj, co napsat do hlavičkových souborů, aby bylo jasný, že je to ode mě. Co by uživatelům říkalo, aby s mojí prácí zacházeli s trochou slušnosti a uváděli moje jméno jako autora, kdyby to chtěli dál šířit nebo upravovat?

C / C++ › Problém s LOD generováním ve…
3. 11. 2012   #165824

ten soubor se dá normálně číst hexeditorem, ale normálně, když to třeba otevřu v klasickým textovým editoru, je to změť znaků, které vypadájí jako z .exe souborů. Je tam spousta proměných a myslím, že nebude těžké zjisti co budou zač. Poradíte nějakou knihovnu, která by s tím byla schopna pracovat?

C / C++ › Template
3. 11. 2012   #165813

Ahoj, můžu v kopírovácím konstructoru prohodiť adresy těch dvou objektů?

C / C++ › Template
23. 10. 2012   #165179

Díky. Snad mám ty nejzávažnější chyby opraveny. Některých věcí jsem si nevšiml. Pokud se vám zdál jeden z předchozích příspěvků nejasných, tak s šablonama teprve začínám a ani jsem nevěděl, jak ten problém pojmenovat. Až budu mít zase čas budu pokračovat. :-)

#pragma once

#include <stdio.h>
#include <stdlib.h>

//namespace Neuron_Class {
	template <class Data, class Synapse>	
	class VECTOROFNEURON
	{
	public:
		VECTOROFNEURON ();
		~VECTOROFNEURON ();
		bool GetNext ();
		bool IsSynapse (Synapse *);
		int GetIncrease (int);
		Synapse *GetSynapse ();
		VECTOROFNEURON<Data,Synapse> *GetTo (int num,int i);
		VECTOROFNEURON<Data,Synapse> *GetTo (Synapse *);
		VECTOROFNEURON<Data,Synapse> *GetLast ();
		VECTOROFNEURON<Data,Synapse> *GetThis ();
		VECTOROFNEURON<Data,Synapse> *ConstructNext ();
		void SetSynapse (Synapse *);
	private:
		Synapse *synapse;
		Data *data;
		VECTOROFNEURON<Data,Synapse> *next;
	};

	class INPUTOFNEURON
	{
	public:
		INPUTOFNEURON ();
		~INPUTOFNEURON ();
	private:
		int *input;
		float *w;
	};
	class OUTPUTOFNEURON
	{
	public:
		OUTPUTOFNEURON ();
		~OUTPUTOFNEURON ();
	private:
	};

	class NEURON
	{
		public:
			NEURON ();
			~NEURON ();
			bool ConstructNewSynapse(NEURON *);
			bool IsSynapse (NEURON *);
			bool SetSynapse(NEURON *, int);
			int GetCountInput ();
			VECTOROFNEURON<INPUTOFNEURON, NEURON> *ConstructInput ();
			VECTOROFNEURON<INPUTOFNEURON, NEURON> *GetFirstInput ();
			VECTOROFNEURON<INPUTOFNEURON, NEURON> *GetInput (int);
			VECTOROFNEURON<INPUTOFNEURON, NEURON> *GetInput (NEURON *);
			VECTOROFNEURON<INPUTOFNEURON, NEURON> *GetLastInput ();

/*			void ConstructOutput ();*/
		private:
			int *output;
			float *p;
			VECTOROFNEURON<INPUTOFNEURON, NEURON> *thisInput;
			VECTOROFNEURON<OUTPUTOFNEURON, NEURON> *thisOutput;
	};
	
	NEURON::NEURON ()
	{
		output = new int;
		p = new float;
		*output = 0;
		*p = 0;
	};

	NEURON::~NEURON ()
	{
		delete output;
		delete p;
	};

	bool NEURON::ConstructNewSynapse(NEURON * rightSide)
	{
		VECTOROFNEURON<INPUTOFNEURON, NEURON> * i;
		i = this->GetInput (rightSide);
		if (i->GetSynapse ())
		{
			return false;
		}
		else
		{
			VECTOROFNEURON<INPUTOFNEURON, NEURON> *j;
			j = this->ConstructInput ();
			j->SetSynapse (j->GetSynapse ());
			return true;
		}

	};
	
	bool NEURON::IsSynapse (NEURON * rightSide)
	{
		if (this->GetFirstInput ())
		{
			if(rightSide == thisInput->GetSynapse ())
			{
				return true;
			}
			else
			{
				return this->IsSynapse (rightSide);
			}
		}
		else
		{
			return false;
		}
	};

	bool NEURON::SetSynapse(NEURON * rightSide, int i)
	{
		
			VECTOROFNEURON<INPUTOFNEURON, NEURON> *j;
			j = this->GetInput (i);
			if (j)
			{
				j->SetSynapse (rightSide);
				return true;
			}
			else
			{
				return false;
			}

	};

	int NEURON::GetCountInput ()
	{
		int i = 0;
		if (this->GetFirstInput ())
		{
			return thisInput->GetIncrease (i);
		}
		return i;
	};

	VECTOROFNEURON<INPUTOFNEURON, NEURON> *NEURON::GetFirstInput ()
	{
		if (thisInput)
			return this->thisInput;
		else
			return 0;
	};

	VECTOROFNEURON<INPUTOFNEURON, NEURON> *NEURON::GetInput (int num)
	{
		int i = 0;
		if (this->GetFirstInput ())
		{
			if (num == i)
			{
				return this->thisInput;
			}
			else
			{
				++i;
				return thisInput->GetTo (num, i);
			}
		}
		else
		{
			return 0;
		}
	};

	VECTOROFNEURON<INPUTOFNEURON, NEURON> *NEURON::GetInput (NEURON *rightSide)
	{
		if (this->GetFirstInput ())
		{
			if (rightSide == thisInput->GetSynapse ())
			{
				return this->thisInput;
			}
			else
			{
				return thisInput->GetTo (rightSide);
			}
		}
		else
		{
			return 0;
		}
	};

	VECTOROFNEURON<INPUTOFNEURON, NEURON> *NEURON::GetLastInput ()
	{
		if (this->GetFirstInput ())
			return thisInput->GetLast ();
		else
			return 0;
	};

	VECTOROFNEURON<INPUTOFNEURON, NEURON> *NEURON::ConstructInput ()
	{
		if (this->GetFirstInput ())
		{
			return thisInput->ConstructNext ();
		}
		else
		{
			thisInput = new VECTOROFNEURON<INPUTOFNEURON, NEURON>;
			return thisInput;
		}
	};

	template <class Data, class Synapse>
	VECTOROFNEURON<Data, Synapse>::VECTOROFNEURON ()
	{
		data = new Data;
	};

	template <class Data, class Synapse>
	VECTOROFNEURON<Data, Synapse>::~VECTOROFNEURON ()
	{
		delete data;
	};

	template <class Data, class Synapse>
	bool VECTOROFNEURON<Data,Synapse>::GetNext ()
	{
		if (next)
			return true;
		else
			return false;
	};

	template <class Data, class Synapse>
	bool VECTOROFNEURON<Data,Synapse>::IsSynapse (Synapse *rightSide)
	{
		if (this->GetFirstInput ())
		{
			if(rightSide == thisInput->GetSynapse ())
			{
				return true;
			}
			else
			{
				return next->IsSynapse (rightSide);
			}
		}
		else
		{
			return false;
		}
	};

	template <class Data, class Synapse>
	int VECTOROFNEURON<Data,Synapse>::GetIncrease (int i)
	{
		if (this->GetNext ())
		{
			++i;
			return next->GetIncrease (i);
		}
		return i;
	};
	
	template <class Data, class Synapse>
	Synapse *VECTOROFNEURON<Data,Synapse>::GetSynapse ()
	{
		return this->synapse;
	};

	template <class Data, class Synapse>
	VECTOROFNEURON<Data,Synapse> *VECTOROFNEURON<Data,Synapse>::ConstructNext ()
	{
		if (this->GetNext ())
		{
			return next->ConstructNext ();
		}
		else
		{
			next = new VECTOROFNEURON<INPUTOFNEURON, NEURON>;
			return next;
		}
	};

	template <class Data, class Synapse>
	VECTOROFNEURON<Data,Synapse> *VECTOROFNEURON<Data,Synapse>::GetTo(int num, int i)
	{
		if (next->GetNext ())
		{
			if (num == i)
			{
				return next;
			}
			else
			{
				++i;
				return this->GetTo (num, i);
			}
			return this;
		}
		else
		{
			return 0;
		}
	};

	template <class Data, class Synapse>
	VECTOROFNEURON<Data,Synapse> *VECTOROFNEURON<Data,Synapse>::GetTo (Synapse *rightSide)
	{
		
		if (rightSide)
		{
			return this;
		}
		else
		{
			if (this->GetNext ())
			{
				return next->GetTo (rightSide);
			}
			else
			{
				return 0;
			}
		}
	};

	
	template <class Data, class Synapse>
	VECTOROFNEURON<Data,Synapse> *VECTOROFNEURON<Data,Synapse>::GetLast ()
	{
		if (this->GetNext ())
		{
			return next->GetLast ();
		}
		else
		{
			return this;
		}
	};
	
	template <class Data, class Synapse>
	VECTOROFNEURON<Data,Synapse> *VECTOROFNEURON<Data,Synapse>::GetThis ()
	{
		return this;
	};

	template <class Data, class Synapse>
	void VECTOROFNEURON<Data,Synapse>::SetSynapse (Synapse * rightSide)
	{
		synapse = rightSide;
	};


	INPUTOFNEURON::INPUTOFNEURON ()
	{
		input = new int;
		w = new float;
		*input = 0;
		*w = rand() % 100 + 0;
		*w = *w/100;
	};
	
	INPUTOFNEURON::~INPUTOFNEURON ()
	{
		delete input;
		delete w;
	};
//};
C / C++ › Template
23. 10. 2012   #165174

No prostě to chci udělat tak, aby mě to neházelo chybu.

C / C++ › Template
23. 10. 2012   #165173

1>------ Rebuild All started: Project: Neural_Network, Configuration: Debug Win32 ------
1>  stdafx.cpp
1>c:\users\verewolf2\desktop\neural_network\neural_network\Neuron.h(206): error C2065: 'rightSide' : undeclared identifier
1>c:\users\verewolf2\desktop\neural_network\neural_network\Neuron.h(206): error C2597: illegal reference to non-static member 'VECTOROFNEURON<Data,NEURON>::NEURON'
1>c:\users\verewolf2\desktop\neural_network\neural_network\Neuron.h(206): error C3867: 'VECTOROFNEURON<Data,NEURON>::NEURON': function call missing argument list; use '&VECTOROFNEURON<Data,NEURON>::NEURON' to create a pointer to member
1>c:\users\verewolf2\desktop\neural_network\neural_network\Neuron.h(206): warning C4346: 'VECTOROFNEURON<Data,NEURON>::GetNext' : dependent name is not a type
1>          prefix with 'typename' to indicate a type
1>c:\users\verewolf2\desktop\neural_network\neural_network\Neuron.h(206): error C2350: 'VECTOROFNEURON<Data,NEURON>::GetNext' is not a static member
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

C / C++ › Můj projekt - Hledání min v…
5. 9. 2012   #162798

#28 ingiraxo
Možná moje příští aplikace v tom bude. :-)

C / C++ › Odhalení chyby
28. 7. 2012   #160746

Na tomhletom příkladu se chci některé algoritmy naučit sám. Jinak se pokouším vytvořit hru mini. Pokud by se mi to povedlo, tak by to byla moje první hra. ;-)

C / C++ › Odhalení chyby
28. 7. 2012   #160743

A taky asi začít používat bloky try, catch a throw :-)

C / C++ › Odhalení chyby
28. 7. 2012   #160742

Tak jsem se pokusil udělat API program, kde jsem chtěl vytvořit pole tlačítek, ale neuvědomil jsem si, že paměť bez příkazu new, delete je velmi omezená (jak že se týhletý paměti říká?, nějak si nemůžu vzpomenout, nemám s kým se o tom bavit.) Docela jsem čuměl, když jsem to zjistil.

Asi bude nejlepší si vytvořit vlastní šablonu třídy pole, která by uměla pracovat s dynamickou pamětí... :-D To jsou ty začátky. :-)

C / C++ › Zjištění pozice oka
27. 7. 2012   #160727

Dík, jak budu mít čas, tak se na to podívám. ;-)

C / C++ › Zjištění pozice oka
27. 7. 2012   #160724

Je nějaká funkce, která mi zjistí pozici okna ve winApi32?

C / C++ › Jak správně vytvoření checkm…
27. 7. 2012   #160714

musí se opravdu vytvořit globální proměnná? #ifndef,#define a #ifend nějak nefungujou. :-(

C / C++ › Jak správně vytvoření checkm…
27. 7. 2012   #160712

#3 liborb
Nic co by nezpravilo #ifndef, aspo+n douf8m. :-D

C / C++ › Jak správně vytvoření checkm…
27. 7. 2012   #160710

   

/* THIS FILE WILL BE OVERWRITTEN BY DEV-C++ */
/* DO NOT EDIT ! */

#ifndef VEREAPP_PRIVATE_H
#define VEREAPP_PRIVATE_H

/* VERSION DEFINITIONS */
#define VER_STRING	"0.1.1.1"
#define VER_MAJOR	0
#define VER_MINOR	1
#define VER_RELEASE	1
#define VER_BUILD	1
#define COMPANY_NAME	""
#define FILE_VERSION	""
#define FILE_DESCRIPTION	"Developed using the Dev-C++ IDE"
#define INTERNAL_NAME	""
#define LEGAL_COPYRIGHT	""
#define LEGAL_TRADEMARKS	""
#define ORIGINAL_FILENAME	""
#define PRODUCT_NAME	""
#define PRODUCT_VERSION	""
#define IDI_ICON 101
#define IDI_HICON 102
#define IDI_HICONSM 103
#define IDT_TIMER 201
#define IDM_NEW 40001
#define IDM_SCORE 40002
#define IDM_END 40003
#define IDM_RULES 40004
#define IDM_ABOUT 40005

#endif /*VEREAPP_PRIVATE_H*/
C / C++ › Jak správně vytvoření checkm…
27. 7. 2012   #160708

Ahoj,

zkouším vytvořit checkmenu, ale nějak mi to nejde. Políčko stále zůstává zaškrtnuté, ikdyž na něj znovu kliknu.

#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include "VereApp_private.h"

/*  Declare Windows procedure  */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);

/*  Make the class name into a global variable  */
char szClassName[ ] = "WindowsApp";

int WINAPI WinMain (HINSTANCE hThisInstance,
                    HINSTANCE hPrevInstance,
                    LPSTR lpszArgument,
                    int nFunsterStil)

{
    HWND hwnd;               /* This is the handle for our window */
    MSG messages;            /* Here messages to the application are saved */
    WNDCLASSEX wincl;        /* Data structure for the windowclass */

    /* The Window structure */
    wincl.hInstance = hThisInstance;
    wincl.lpszClassName = szClassName;
    wincl.lpfnWndProc = WindowProcedure;      /* This function is called by windows */
    wincl.style = CS_DBLCLKS;                 /* Catch double-clicks */
    wincl.cbSize = sizeof (WNDCLASSEX);

    /* Use default icon and mouse-pointer */
    wincl.hIcon = LoadIcon (hThisInstance, MAKEINTRESOURCE("IDI_HICON"));
    wincl.hIconSm = LoadIcon (hThisInstance, MAKEINTRESOURCE("IDI_HICONSM"));
    wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
    wincl.lpszMenuName = "MAINMENU";                 /* No menu */
    wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */
    wincl.cbWndExtra = 0;                      /* structure or the window instance */
    /* Use Windows's default color as the background of the window */
    wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;

    /* Register the window class, and if it fails quit the program */
    if (!RegisterClassEx (&wincl))
        return 0;

    /* The class is registered, let's create the program*/
    hwnd = CreateWindowEx (
           0,                   /* Extended possibilites for variation */
           szClassName,         /* Classname */
           "Vere App",       /* Title Text */
           WS_OVERLAPPEDWINDOW, /* default window */
           CW_USEDEFAULT,       /* Windows decides the position */
           CW_USEDEFAULT,       /* where the window ends up on the screen */
           544,                 /* The programs width */
           375,                 /* and height in pixels */
           HWND_DESKTOP,        /* The window is a child-window to desktop */
           NULL,                /* No menu */
           hThisInstance,       /* Program Instance handler */
           NULL                 /* No Window Creation data */
           );

    /* Make the window visible on the screen */
    ShowWindow (hwnd, nFunsterStil);

    /* Run the message loop. It will run until GetMessage() returns 0 */
    while (GetMessage (&messages, NULL, 0, 0))
    {
        /* Translate virtual-key messages into character messages */
        TranslateMessage(&messages);
        /* Send message to WindowProcedure */
        DispatchMessage(&messages);
    }

    /* The program return-value is 0 - The value that PostQuitMessage() gave */
    return messages.wParam;
}


/*  This function is called by the Windows function DispatchMessage()  */

LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
        HDC hDC;
        HMENU hMenu;
        PAINTSTRUCT ps;
        RECT rect;
        int posX = 0;
        int posY = 0;
        UINT checkRules = 0;
        char buffer [33];
        switch (message)                  /* handle the messages */
        {
               case WM_COMMAND:
                    hMenu = GetMenu(hwnd);
                    switch (wParam)
                    {
                           case IDM_NEW:
                                SetTimer(hwnd,IDT_TIMER,500,NULL);
                                break;
                           case IDM_END:
                                PostQuitMessage (0);
                                break;
                           case IDM_RULES:
                                switch (checkRules)
                                {
                                       case 0:
                                               CheckMenuItem(hMenu, IDM_RULES, MF_CHECKED);
                                               checkRules = 1;
                                               break;
                                       default:
                                               CheckMenuItem(hMenu, IDM_RULES, MF_UNCHECKED);
                                               checkRules = 0;
                                               break;
                                }
                                break;
                    }
                    break;
                    case WM_PAINT:
                    
                    break;
               case WM_TIMER:
                    switch (wParam)
                    {
                           case IDT_TIMER:
                                SetWindowPos(hwnd,NULL,++posX,++posY,512,256 ,NULL);
                                break;
                    }
                    break;
               case WM_DESTROY:
                    PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
                    break;
               default:                      /* for messages that we don't deal with */
                    return DefWindowProc (hwnd, message, wParam, lParam);
        }
        return 0;
}
#include "VereApp_private.h"
#include "afxres.h"

IDI_ICON ICON DISCARDABLE "Resource/Icon.ico"
IDI_HICON ICON DISCARDABLE "Resource/hIcon.ico"
IDI_HICONSM ICON DISCARDABLE "Resource/hIconSM.ico"

MAINMENU MENU DISCARDABLE
BEGIN
         POPUP "&Game"
         BEGIN
              MENUITEM "&New Game",               IDM_NEW
              MENUITEM "&Score",                  IDM_SCORE
              MENUITEM "&End",                    IDM_END
         END
         POPUP "&Help"
         BEGIN
              MENUITEM "&Rules",                  IDM_RULES
              MENUITEM "&About App",              IDM_ABOUT
         END
END
VereWolf
C / C++ › Problém s kopírovacím konstr…
26. 6. 2012   #159516

#6 Martin Kozibrátka
Dík.

VereWolf
C / C++ › Problém s kopírovacím konstr…
26. 6. 2012   #159510

Ještě by mě zajímalo, jak nejlépe udělat to dělení. Abych to nemusel dávat do kopírovacího constructoru. Když jsem se vzorec pokusil vložit do funkce GetResultValue (), tak mě to napsalo:

30 C:\Users\VereWolf2\Desktop\Untitled1.cpp:49 assignment of member 'Division::itsResultValue' in read-only object

#include <iostream>

using namespace std;

class Division
{
      public:
            Division ();
            Division (Division&);
            ~Division ();
            float GetDownValue () const {return itsDownValue;}
            float GetResultValue () const;
            float GetUpValue () const {return itsUpValue;}
            void SetDownValue (float downValue) {itsDownValue = downValue;}
            void SetUpValue (float upValue) {itsUpValue = upValue;}
            class xNullDownValue {};
      private:
              float itsDownValue;
              float itsResultValue;
              float itsUpValue;
};

Division::Division ():
                      itsDownValue(1),
                      itsResultValue(0),
                      itsUpValue(0)
                      {
                                   cout << "Constructor" << endl;
                      }

Division::Division (Division& object)
                              {
                                   cout << "copy Constructor" << endl;
                                   if (object.itsDownValue == 0)
                                   {
                                      throw xNullDownValue();
                                   }
                                   itsDownValue = object.GetDownValue ();
                                   itsUpValue = object.GetUpValue ();
                                   itsResultValue = itsUpValue / itsDownValue;
                               }
                               
Division::~Division ()
                      {
                               cout << "Destructor" << endl;
                      }
float Division::GetResultValue () const
{
    itsResultValue = itsUpValue / itsDownValu;
    return itsResultValue;
}

int main(int argc, char *argv[])
{
    try
    {
        float down,up;
        Division first;
        cout << "Napis horni hodnotu: ";
        cin >> up;
        cout << endl;
        first.SetUpValue(up);
        cout << "Napis dolni hodnotu: ";
        cin >> down;
        cout << endl;
        first.SetDownValue(down);
        Division two = first;
        cout << first.GetResultValue () << endl;
        cout << two.GetResultValue () << endl;
    }
    catch (Division::xNullDownValue)
    {
        cout << "Down value is Null!" << endl;
    }
    catch (...)
    {
        cout << "error!" << endl;
    }
    cout << "Press the enter key to continue ...";
    cin.get();
    cin.get();
    return 0;
}
VereWolf
C / C++ › Problém s kopírovacím konstr…
26. 6. 2012   #159503

#3 fnenks
Ok dík. Proč jste měnil to throw, když to funguje stejně? No prostě bych rád pokračoval dál v studiu, a když občas narazím na něco, co mi není jasné, tak bych se rád zeptal nebo vyhledal. :-)

VereWolf
C / C++ › Problém s kopírovacím konstr…
25. 6. 2012   #159490

Zdravím, mám problémy s kopírovacím konstructorem, který se nevolá, když požiju kteroukoliv funkci v třídě. Mám přečtenou knihu Naučte se C++ za 21 dní (2007).Zde je příklad:

 

#include <iostream>

using namespace std;

class Division
{
      public:
            Division ();
            Division (Division&);
            ~Division ();
            float GetDownValue () const {return itsDownValue;}
            float GetResultValue () const {return itsResultValue;}
            float GetUpValue () const {return itsUpValue;}
            void SetDownValue (float downValue) {itsDownValue = downValue;}
            void SetUpValue (float upValue) {itsUpValue = upValue;}
            class xNullDownValue {};
      private:
              float itsDownValue;
              float itsResultValue;
              float itsUpValue;
};

Division::Division ():
                      itsDownValue(1),
                      itsResultValue(0),
                      itsUpValue(0)
                      {
                                   cout << "Constructor" << endl;
                      }

Division::Division (Division&)
                              {
                                   cout << "copy Constructor" << endl;
                                   if (itsDownValue == 0)
                                   {
                                      throw xNullDownValue();
                                   }
                                   itsResultValue = itsUpValue/itsDownValue;
                               }
                               
Division::~Division ()
                      {
                               cout << "Destructor" << endl;
                      }
                               

int main(int argc, char *argv[])
{
    try
    {
        Division first;
        cout << first.GetResultValue () << endl;
    }
    catch (Division::xNullDownValue)
    {
        cout << "Down value is Null!" << endl;
    }
    catch (...)
    {
        cout << "error!" << endl;
    }
    cout << "Press the enter key to continue ...";
    cin.get();
    return 0;
}

 

 

Hostujeme u Českého hostingu       ISSN 1801-1586       ⇡ Nahoru Webtea.cz logo © 20032024 Programujte.com
Zasadilo a pěstuje Webtea.cz, šéfredaktor Lukáš Churý