I want to create events and then, functions which are subscribed to the event can access information about the event. For example, in Class 2 below, I want it to be able to access things such as touch.position, etc. of class 1.
Class 1:
public delegate void TouchEventHandler (EventArgs e);
public event TouchEventHandler TouchBegan;
public Vector2 touchPosition;
void Update () {
if (Input.touchCount > 0) {
#include <cstdlib> #include <iostream> struct tax_node { char form; // tax form letter int version; // tax form number
[Code] ....
I cannot seem to get why function print_contents will not work. The couts at the end of the program is just to test that it printed correctly. But, if I need it to print the contents such when print_contents(ptr2) is called. I think it should be tax_ptr in the parameter list but I am not quite sure.
Write a program that inputs 10 integers from the console into an array, and removes the duplicate array elements and prints the array. By removing, I mean that you should make it appear as if the elements hadn't been there. You may assume that all the integers are between 0 and 100, Write at least 1 function in addition to the main function, and pass an array into that function as a parameter. e.g.
Please enter your 10 numbers: 1 2 3 4 5 6 7 8 9 10 The array contains: 1 2 3 4 5 6 7 8 9 10
Please enter your 10 numbers: 1 1 3 3 3 6 7 8 9 9 The array contains: 1 3 6 7 8 9
Please enter your 10 numbers: 1 1 1 1 1 1 1 1 1 1 The array contains: 1
The bolded area is where I'm having trouble. How I can go about doing this, passing an array into the function as a parameter?
Here is my code:
#include "stdafx.h" #include <iostream> using namespace std; int main () { const int MAX = 10; int a[MAX] = {0}; int i;
Pseudocode: template<typename T /*, some parameter for member_function */> class Foo { public: void someFunction() { T t; t.member_fuction(...); } }
I'm trying to make the call to T::member_function a templated value because member_function might vary by name in my scenario. Since std::mem_fn isn't a 'type', i can't do something like Foo<std::string, std::mem_fn(&std::string::clear)> foo;
I also want to take into account that member_function might have more than one parameter. That is, the first parameter will always be something known but there might be other defaulted parameters.
The only thing I can think of is to make a proxy structure, something like this:
But when I try to build it, I get this error on line 24:could not convert template argument 'lambda' to 'void (*)(const string&) {aka void (*)(const std::basic_string<char>&)}'|
I thought the lambda expression I wrote would decay to a function pointer matching the template parameter. I can guess that the constexpr qualifier might have changed the type, but without it my compiler complains that lambda needs to be declared as constexpr...
So is there a way to pass lambda expressions as template parameters?
I created the following code to pass the the variable 'inputVoltage' by reference to the function 'input'. It certainly works when I run the program, but I dont think it is a standard way of doing it, i.e. the use of '*' and '&' is not according to convention ? Or perhaps the way did it is acceptable ?
int input (double *inputVoltage); int main ( { double inputVoltage; input(&inputVoltage);
I have a class and I would like to be able to pass an extra parameter to the function that is executed.
BigInt operator / (BigInt N,BigInt D) { ... }
is what I have now. but I would like to do something like this. so the default value for a is 10. and if the user does something like N/D (12) Then the value of a is 12.
Here is my issue: I am making a simple audioplayer in Xamarin.android but i want every time i change the track to make a crossfade effect. So im using 2 mediaplayers at the same time for the fade. The problem is that im defining one time the players and i pass the player as a parameter like this:
public MediaPlayer player = null; public MediaPlayer player2 = null; ....
If i have to fadeout the player and start the next one im doing it like this:
if (player != null){ if (player.IsPlaying) { cts = new CancellationTokenSource(); token = cts.Token; FadeOut (player, 2000 ,token);
[Code] .....
So my problmem is that player and player2 remain always null. Why? i guess c# creates a copy of player and player2 and use this one. How i can pass a mediaplayer as parameter and always use only player and player2?
I have a class matrixType that has some overloaded operators (+, -, *, and <<). With a view to having clearly-delineated, perfectly-formatted, four-sided matrices, as shown below:
A = 1 2 3 4 5 6 7 8 9 or A + B = 1 2 3 4 5 6 7 8 9
and NOT this jagged ones shown below:
A = 1 2 3 4 5 6 7 8 9
or
A + B = 1 2 3 4 5 6 7 8 9 ,
I want a scheme in which the string literals (A, A+B, etc.) could be passed as parameters to the overloaded stream insertion (<<) operator function so that I could use the string’s length to determine how much offset from the display screen’s left to apply to each matrix’s row (by using the setw() function). However, I do know that the << operator is a binary operator, meaning the function cannot take more than two parameters: that is what compounds my problem!
Basically I'm trying to pass an object as a reference to the template function, rather than a copy as it's seeing. I'm needing to do this without editing Obj::Call to accommodate a reference as its first parameter, as it'd break other calls.
You'll notice in the following code the object will be destroyed upon passing, while the object defined is still in-scope due to the infinite end loop.
#include <iostream> #include <string> using namespace std; class Obj { public: string name; Obj(string name): name(name) {cout << "create " << this << endl;}
[code]....
In the past I tried ref(), which appeared to stop this happening, however it created a blank copy of the object instead.
My errors are at the end of the program in two function calls within the definition of the InsertByValue function. g++ does not seem to recognize NumArray as a valid parameter.
#include <iostream> #include <assert.h> using namespace std; const int CAPACITY = 20;
/* Displays the content of an int array, both the array and the size of array will be passed as parameters to the function @param array: gives the array to be displayed @param array_size: gives the number of elements in the array */ void DisplayArray (int array[], int array_size);
bool validateNumber(string& text, int min = 0, int max = -1, bool useMin = true, bool getValid = true)
The code takes the string text, and checks the make sure that the input is valid and safe to convert and use as a number. However, sometimes there is not min, and sometimes there is no max. The lack of min is done by using the parameter useMin, while the lack of max is done by max < min.
My predicament is the following call: validateNumber(text, -2);
Now, max will be used, even though I don't want it. Ideally, I would want to do something like... int max = (min - 1), ... but that doesn't work. I also can't check to see if the parameter hasn't been changed (that I know of), because the following call would make it look like it hasn't validateNumber(text, -2, -1);
So the question is, is there a way to do what I want, without having to add in a bool useMax parameter? Or is this my only option? I don't want to do that for simplicity, but if I have to, I have to.
i need to change the text in multiple ComboBoxs. i could do it one by one, but i have about 11 i need to change. i feel like doing it one at a time is not efficient. i was wondering if i can put the comboboxs into an array so i can use a for loop to change them all with out writeing it out 11 times.
I am writing a application that receives Event messages from a network device the problem I have is that the device sends some message 5 times per tiggered event on two of the events I like to use the rest of the messages are fine I need to create code to filter out the other 4 last messages that get displayed in a textbox the 5 message are identical I have added a timestamp to the sting and noted they are always 1 second apart so the format would be somthing like this:
11:23:01 - x - y 11:23:02 - x - y 11:23:03 - x - y 11:23:04 - x - y 11:23:05 - x - y
What I would like to do something like this, always append the first message to the textbox but ignore or even change the 4 messages that follow 1 second apart from each other that contain - x - y if any other message appears it should still append the text box as well
so the result i would like for the 5 event message as above should end like this:
11:23:01 - x - y 11:23:02 - custome message / ingnore append to textbox 11:23:03 - custome message / ingnore append to textbox 11:23:04 - custome message / ingnore append to textbox 11:23:05 - custome message / ingnore append to textbox
I want to update a label from Form2. When I click on the button on Form 2, the textbox on Form2 should update the label on Form1 and take me to a certain website. What ever URL is typed into the textbox on Form2 is what website URL the label on Form1 will take me to. The label on Form1 can say something such as You can check out my website here!!! and when they click on the saying it takes me to their website.
I'm still at the very beginning of learning WPF and there are still countless things i don't fully understand. For instance, as I can see in my WPF project, there isn't an event that would fire when the Background property of some control is changed. Or am I just missing it? If i'm not blind after all, and it really doesn't exist, is there any way i could get notified when the Background color of some control is changed?
I'm trying to find an event for the combobox when its selected value changes , but I can't seem to find the right one since I've tried several events in the dataGridView that are just triggering at the wrong moments. I need to remove the selected item from that combobox so that it doesn't get selected again at the second combobox which usually have the same items .
In my MainWindow I have a UserControl called CamAccessLevel1. This will be one of a few different UserControls which will have more and more functionality to a device as the Level goes up.
Each of those functionalities are themselves a UserControl, so that I don't have to keep remaking them for each different "Level" that I make.
So... I have a UserControl in a UserControl in my Mainwindow. My first goal is to have a button in one of those sections send an event back to the MainWindow to close the application. This sections is called "ProgramControl", as it has functions that relate to the program itself.
I can't seem to set a datacontext within another datacontext -> There is an error in UIViewModel below...
Note that I have replaced my company name with [snip]
In my Mainwindow.xaml <views:CamAccessLevel1 x:Name="UserInterface"/> Mainwindow.xaml.cs public partial class MainWindow : Window { #region MyModel