class

Copying variables from one picturebox to another without making them change with each other

岁酱吖の 提交于 2019-12-25 13:46:09
问题 I would like to copy a picturebox to another picturebox, but I do not want them to change with each other. PictureBox picbox1 = new PictureBox(); PictureBox picbox2 = picbox1; picbox1.Visible = false; //The problem here is that picbox2.Visible will also become false I would like to make picbox1 change without changing picbox2 .... How would I be able to do that? 回答1: Probably the best way to maintain clean code is to create an extension method, also note that your second picturebox is

Class attributes not passing to objects

烂漫一生 提交于 2019-12-25 11:59:09
问题 I'm trying to create a very basic RPG-like game where you select a character, give that character a weapon, and then tell it to attack another character with damage based on the stats of the character and the weapon. The weapon class belongs to a top level class called Equip . When I try to set an attack damage variable that incorporates the weapon's stats, however, I get: 'Char' object has no attribute 'weapon.' I have the Char class weapon value set to None as default. But below, I have

Overload operators to work with class objects?

ぃ、小莉子 提交于 2019-12-25 10:38:30
问题 How can I modify the following code in such way I don't need to repeat f2=11; f3=12; in the main function. The code is for overloading the most common operators. class FLOAT{ private: float x; public: FLOAT(){ x=0.0; } void setFloat(float f) { x=f; } float getFloat() { return x;}; FLOAT operator+(FLOAT obj) {x=x+obj.x; return *this;}; FLOAT operator-(FLOAT obj) {x=x-obj.x; return *this;}; FLOAT operator*(FLOAT obj) {x=x*obj.x; return *this;}; FLOAT operator/(FLOAT obj) {x=x/obj.x; return

Overload operators to work with class objects?

删除回忆录丶 提交于 2019-12-25 10:37:03
问题 How can I modify the following code in such way I don't need to repeat f2=11; f3=12; in the main function. The code is for overloading the most common operators. class FLOAT{ private: float x; public: FLOAT(){ x=0.0; } void setFloat(float f) { x=f; } float getFloat() { return x;}; FLOAT operator+(FLOAT obj) {x=x+obj.x; return *this;}; FLOAT operator-(FLOAT obj) {x=x-obj.x; return *this;}; FLOAT operator*(FLOAT obj) {x=x*obj.x; return *this;}; FLOAT operator/(FLOAT obj) {x=x/obj.x; return

Overload operators to work with class objects?

久未见 提交于 2019-12-25 10:36:50
问题 How can I modify the following code in such way I don't need to repeat f2=11; f3=12; in the main function. The code is for overloading the most common operators. class FLOAT{ private: float x; public: FLOAT(){ x=0.0; } void setFloat(float f) { x=f; } float getFloat() { return x;}; FLOAT operator+(FLOAT obj) {x=x+obj.x; return *this;}; FLOAT operator-(FLOAT obj) {x=x-obj.x; return *this;}; FLOAT operator*(FLOAT obj) {x=x*obj.x; return *this;}; FLOAT operator/(FLOAT obj) {x=x/obj.x; return

Overload operators to work with class objects?

橙三吉。 提交于 2019-12-25 10:36:35
问题 How can I modify the following code in such way I don't need to repeat f2=11; f3=12; in the main function. The code is for overloading the most common operators. class FLOAT{ private: float x; public: FLOAT(){ x=0.0; } void setFloat(float f) { x=f; } float getFloat() { return x;}; FLOAT operator+(FLOAT obj) {x=x+obj.x; return *this;}; FLOAT operator-(FLOAT obj) {x=x-obj.x; return *this;}; FLOAT operator*(FLOAT obj) {x=x*obj.x; return *this;}; FLOAT operator/(FLOAT obj) {x=x/obj.x; return

C++ class template specialization with pointers

与世无争的帅哥 提交于 2019-12-25 10:00:32
问题 I have a tree structure of the following format: template <typename DataType> class Tree { DataType *accessData() { return data; } Tree *child1, *child2; DataType *data; }; template <typename DataType> class Root : public Tree<DataType> { // root provides storage of nodes; when it goes out of scope, the // entire tree becomes invalid MemoryPool<Tree> nodeStorage; MemoryPool<DataType> dataStorage; }; I use a variety of instantiations of this template in my program. It works quite well. One

How to get an object class into SQL Query c#?

梦想的初衷 提交于 2019-12-25 09:25:59
问题 I would like to put the values of object 'gebruiker' from class 'Gebruikersklasse' to the query in the buttonclick. The query will be sent to the 'Databaseconnection' class and will be executed there. I'm getting an error if I run this. It tells me that gebruikers.Naam can't be found. So he can't find an object called 'gebruiker' I think? If I change the query to manually values, it works. I am using these classes: using System; using System.Collections.Generic; using System.Linq; using

Complex number program compile-time error at calculation methods

你说的曾经没有我的故事 提交于 2019-12-25 09:18:23
问题 class Complex { public: Complex(float = 0.0, float = 0.0); //default constructor that uses default arg. in case no init. are in main void getComplex(); //get real and imaginary numbers from keyboard void sum(Complex, Complex); //method to add two complex numbers together void diff(Complex, Complex); //method to find the difference of two complex numbers void prod(Complex, Complex); //method to find the product of two complex numbers void square(Complex, Complex); //method to change each

C++ calling another class constructor

孤人 提交于 2019-12-25 09:17:07
问题 I am starting to learn about C++ classes and I have a problem. I read about constructors and initialization lists, but I still can't manage to solve my problem. Code in foo.h: class point{ public: double x,y; point(double x1, double y1); }; class line: public point{ public: double A,B,C; double distance(point K); line(point M, point N); }; And in foo.cpp: point::point(double x1, double y1){ x=x1; y=y1; } line::line(point M, point N){ if(M.x!=N.x){ A=-(M.y-N.y)/(M.x-N.x); B=1; C=-(M.y-A*M.x);