I have a method to take a Tile object and make an instances of it based on some data from the original object. Than it is suppose to manipulate the a specific instance and save the results. The first loop through it works but it changes all instance as well as the base.
public static int recurse(int count, Tile[,] b,Huristic h,int check) { if (check==1) { boardState.Add(B)/>; return check; } if (check == 0)
I am new to c++ and trying to learn. for instance. i have a struct and method.I am trying to learn what i can do with the method if i define the return type as struct type.
struct S { int age; string name; }; S method() { //what i can do in here. with the Struct. I mean can i reach members of the struct. etc }
I got base class called Statistic and inherited classes from it : lsp, cpu, memory. Those methods inheriting some of methods from Statistic and implement also theirself methods. I prepared some new class called ExecuteRequest which is taking Statistic object in the constructor. What i want to achieve is after i put e.g LSP to this class i would like to determinate what specific object it is in this case LSP right? Then having that i would like to put this object to RunRequest method. How can i achieve that? See my code below:
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SOAP_testing { public class ExecuteRequest
public class Customer { public int Id { get; set; } public string Name { get; set; } public List<Order> Orders { get; set; } public Customer() { Orders = new List<Order>(); } }
This object is called as
var cust = new Customer { Id = 1, Name = "Khatana", [b]Orders.Add(new Order())[/b] }
I want to ask, Orders.Add(new Order()) is a wrong way, but why..!!... as List<Order> already has been initialized in Customer constructor, then why it is again required to be initialized in object initialization. Is this a correct way
List<Order> orders = new List<Order> {aaa.....bb....cc}; var cust = new Customer { id = 1, Name = "Khatana", Orders = new List<Order> { orders } }
Why we need to initialize a list in an object initialization, where as the list has been already initialized in object constructor.
i'm using DataGridView and the sorting operation,by clicking the column header, is working fine , but when i add the drag and drop operation it doesn't respond . i think it can be fixed by disabling the drag and drop for the headers, but i just couldn't find a way to do that.
I'm trying to implement keyboard controls to move a sphere(Player) with respond to keypress. Currently, when I press any key my character will move to the right by 0.1. How can I move my character with w(up),a(left),s(down),d(right) in their respective directions using respond to keypress?
Code: class Player { private: double x, y; public: Player(double a, double b){x=a;y=b;} void respondtokeypress(char a)
I have a problem in a c++ project. I have created a .dll file and hooked to an .exe
I want this .dll to make a ping or to send a message like hello somewhere, and IF ping or message doesn't receive an answer that's means the user has suspended-terminated this dll from the exe then the exe will close. How can i do that?
I've been trying for more than one month to access a method found in a library called libcocosnas_static.a. I'm using Cocos2d-X version 2.0.4. The library has been used many times by my company to make games using cocos2d-1.0.1-x-0.12.0 without any problem.
This is what I've done: 1- I added the include paths of the library to both eclipse and Android.mk 2- Included the .h file using #include "NASPlatformUtil.h" 3- Added the libcocosnas_static.a file to the proj.androidobjlocalarmeabi folder 4- Added "LOCAL_WHOLE_STATIC_LIBRARIES += cocosnas_static" to the Android.mk file 5- Called the function using: NASPlatformUtil:: openUrl("http://xxx.xxx.com/");
I can right click on the function, click Open Declaration and get it without any problem, but the compiler keeps on giving me that dreaded error...
I am looking for direction on what topic I should be reading up on. I am new to C++ and Windows MFC.
This is my real world problem, in the context of the application user. (these term do not refer to OPP concepts)
I want to create shapes (containers) in an application that will respond and collect other objects;
Imagine a Windows frame, containing several 2 dimensional squares. I want to be able to drag and drop marbles into the squares,and have the square retain and display the marbles in the square, in the order that they were dropped in.
How do I create the shapes, and how will the square sense when a marble is over it?
How would I create irregular shapes (a combination of lines and curves) that would be responsive to the marbles?
I am trying to write a loop that will iterate through a char array in C and pull the IP addresses and test them to see if they respond. My ultimate goal is to have the first one that responds returned in the function, but the loop is not running correctly. It will run through right the first time, but then will start over again.
Code output: Contents of srList b4 loop: 1.1.1.1 Server List: 1.1.1.1 result is "1.1.1.1" Hitting else loop Contents of srList in else: 2.2.2.2 result is "2.2.2.2" result is "2.2.2.2" Contents of srList b4 loop: 1.1.1.1 Server List: 1.1.1.1 result is "1.1.1.1" Hitting else loop Contents of srList in else: (null)
I have a question similar to the one here: [URL] .....
The main difference is I would like to pass a method of derived class as a parameter to some other method in its template base class.
template <typename BaseType> class Base { public: typedef void (Base::*Callback)(int A);
[Code] .....
The above is an example which does not compile. My compiler complains that the two BaseMethod() calls in DerivedMethod() are invalid uses of non-static member function.
Is this not possible to do, or is my syntax simply wrong? All I want is to be able to pass as an an argument to a method in the base class from the derived class some callback as a variable for the base class to invoke later.
will copy constructor does object initialization using another already created object? I understand that it can be applied for object initialization and not for assignment.Is it correct?
this function will return a temporary integer now void fun1(const int & num); this function can receive from myfun().BUT void fun2(int & num); this function cannot receive from myfun() Why is that, Moreover what is lifetime of a temporary object like one returned in myfun() ???
I am using the above code to retrive an item selected by user,But this line is giving an exception "Null Reference Exception, Object reference not set to an instance of an object"
In Visual Studio 2010 C++ I have a series of existing text objects The text properties names are item1_lbl, item2_lbl, item3_lbl, ….
Based on a selection I want to change an object. I generate the name of the object I want to change in a string so from this string is there a way to get a pointer to the correct text object that is same name?
I'm trying to figure out how I can create a vertex array object at offset of a vertex buffer object.I've created the buffer object. I'd like the "texs" idnex data to start at the texture coordinate content of the vertex_t structure.
Type definitions:
struct vertex_t { vector3d_t position; float s; // Texture coordinate s float t; // Texture coordinate t };
Code so far:
// How do I make this start at a certain spot of the VBO?! glVertexAttribPointer(texs, 2, GL_FLOAT, GL_FALSE, sizeof(vector3d_t), nullptr; //...
#include <iostream> using namespace std; struct A { virtual void f() { cout<<"A "; } };
[code]...
I would expect that both examples 2 & 3 will give me the same result.I tried to figure it out but I could not. Both are references of a base class type, that get a derived object.
Q1 : why is the difference between them ?
As I see it, its kind of a mix between pointer - which in case of virtual method that was override in derived class - would give me the derived method (e.g. "B") and between regular object - which in case of virtual method that was override - would give me the specific method (Still "B"). So, example 2 "use" it as a regular object and example 3, "use" it as pointer.
Q2 : How should I refer to it ? I am using VS2008.
I have 2 classes with a Function with the same definition (both inherited from the same base class) and in my derived class I derive from both of those 2. Is it possible to use the Methods of both classes? for example with an other name?
class A { protected: int print(int a) { std::cout << "int A: " << a << std::endl; } }; class B : A
[Code] ....
is there something like using C::print as printc;?
The Problem, I have a Sprite class that derives from a Rectangle with properties Position, Size, Origin and Angle and a Text class that derives from Rectangle. Now i have a Button class deriving from both Sprite and Text.
- The Position, when moving the Button i have to change the position of both so i Implemented a new Method which calls SetPosition from the Sprite and the Text. - The SetSize just affects the Button so i just did using Sprite::SetSize; - The angle affects both so i just implemented a new Method and hide the other two
The problem is here: - The Origin: writing button.SetOrigin(-1,0) should set the Origin of the Button and writing button.SetTextOrigin should set the Origin of the text.
Should i just reimplement a Mehtod named SetTextOrigin and call Text::SetOrigin from there and hide the button.Text::SetOrigin or is there something like using Text::SetOrigin as SetTextOrigin?
It has been a few years since I have had to do this, but I need to declare a method in my base class, but produce no code for it. Then when this library is used by my second project I will derive a class from this base class and put the code into it there. How is this possible? I used to know how but do not remember how now.
The library is a static library designed for linking with both 32bit and 64bit Windows applications to handle a lot of the tedious stuff with Windows programming. The method in question handles specific command inputs. However, since each program that uses this library will have different uses for these commands, I want to leave it up to the user to code their own handling, but require it to be coded in the derived class.